Skip to main content

Chained

Trait Chained 

Source
pub trait Chained: Resource {
    type Base: Resource;

    // Required methods
    fn chain() -> RecordId;
    fn part_for(
        action: &Self::Action,
        parts: &[(u64, Rc<Self::State>)],
    ) -> Result<u64, String>;

    // Provided methods
    fn chain_beside(base: &RecordId) -> RecordId { ... }
    fn prepare(
        action: &mut Self::Action,
        base: &<Self::Base as Resource>::State,
    ) -> Result<(), String> { ... }
    fn carry(previous: u64, part: &Self::State) -> Option<Invoke<Self>> { ... }
    fn place(
        action: &Self::Action,
        base: &<Self::Base as Resource>::State,
    ) -> Option<String> { ... }
}
Expand description

A resource whose records are the parts of a chain kept beside the app’s own record (RecordId::part). See the module docs.

Required Associated Types§

Source

type Base: Resource

The app’s own resource: what Self::prepare reads where an action is invoked.

Required Methods§

Source

fn chain() -> RecordId

The chain the parts belong to: part n is chain().part(n).

Source

fn part_for( action: &Self::Action, parts: &[(u64, Rc<Self::State>)], ) -> Result<u64, String>

The part action changes, given the parts this device holds, oldest first: the one holding the item it names, or for a new item the head (or the next part, once the head is full).

Provided Methods§

Source

fn chain_beside(base: &RecordId) -> RecordId

The chain that belongs beside base rather than beside the app’s own record: the messages of one conversation, kept beside its record (RecordId::of_direct). Self::chain for every chain there is only one of.

Source

fn prepare( action: &mut Self::Action, base: &<Self::Base as Resource>::State, ) -> Result<(), String>

Fill in, where the action is invoked, what it records from the app’s own record (who a mention names), and refuse what that record does not allow (a post to a channel it has not got). A part’s action itself reads only its part, so it replays the same on every replica.

Source

fn carry(previous: u64, part: &Self::State) -> Option<Invoke<Self>>

What a part started after part previous (whose state is part) carries of the parts before it, written into it as it starts, before the action that started it: a summary a reader needs of parts it does not hold (a chat’s message counts for unread badges). Whoever starts a part holds the one before. None carries nothing.

Source

fn place( action: &Self::Action, base: &<Self::Base as Resource>::State, ) -> Option<String>

Where in the app’s own record action happens, named as everyone the record is shared with sees that place (a post’s channel, #general): history keeps it on the step (tilo_actions::PLACE_FACET), so what someone is doing can say where. None for an action of no such place, and for a place not everyone sees (a direct conversation).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§