fractal::session::model::room::timeline::timeline_item_diff_minimizer

Trait TimelineItemStore

Source
pub(super) trait TimelineItemStore: Sized {
    type Item: IsA<TimelineItem>;
    type Data: TimelineItemData;

    // Required methods
    fn items(&self) -> Vec<Self::Item>;
    fn create_item(&self, data: &Self::Data) -> Self::Item;
    fn update_item(&self, item: &Self::Item, data: &Self::Data);
    fn apply_item_diff_list(
        &self,
        item_diff_list: Vec<TimelineItemDiff<Self::Item>>,
    );

    // Provided methods
    fn can_minimize_diff_list(
        &self,
        diff_list: &[VectorDiff<Self::Data>],
    ) -> bool { ... }
    fn minimize_diff_list(&self, diff_list: Vec<VectorDiff<Self::Data>>) { ... }
}
Expand description

Trait to access data from a type that store TimelineItems.

Required Associated Types§

Required Methods§

Source

fn items(&self) -> Vec<Self::Item>

The current list of items.

Source

fn create_item(&self, data: &Self::Data) -> Self::Item

Create a TimelineItem with the given TimelineItemData.

Source

fn update_item(&self, item: &Self::Item, data: &Self::Data)

Update the given item with the given timeline ID.

Source

fn apply_item_diff_list( &self, item_diff_list: Vec<TimelineItemDiff<Self::Item>>, )

Apply the given list of item diffs to this store.

Provided Methods§

Source

fn can_minimize_diff_list(&self, diff_list: &[VectorDiff<Self::Data>]) -> bool

Whether the given diff list can be minimized by calling minimize_diff_list.

It can be minimized if there is more than 1 item in the list and if the list only includes supported VectorDiff variants.

Source

fn minimize_diff_list(&self, diff_list: Vec<VectorDiff<Self::Data>>)

Minimize the given diff list and apply it to this store.

Panics if the diff list contains unsupported VectorDiff variants. This will never panic if can_minimize_diff_list returns true.

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§