pub trait ConsolidateLayout: Container {
    type Key<'a>: Eq
       where Self: 'a;
    type Diff<'a>: IntoOwned<'a, Owned = Self::DiffOwned>
       where Self: 'a;
    type DiffOwned: for<'a> Semigroup<Self::Diff<'a>>;

    // Required methods
    fn into_parts(item: Self::Item<'_>) -> (Self::Key<'_>, Self::Diff<'_>);
    fn push_with_diff(&mut self, key: Self::Key<'_>, diff: Self::DiffOwned);
    fn cmp(item1: &Self::Item<'_>, item2: &Self::Item<'_>) -> Ordering;
}
Expand description

Layout of containers and their read items to be consolidated.

This trait specifies behavior to extract keys and diffs from container’s read items. Consolidation accumulates the diffs per key.

The trait requires Container to have access to its Item GAT.

Required Associated Types§

source

type Key<'a>: Eq where Self: 'a

Key portion of data, essentially everything minus the diff

source

type Diff<'a>: IntoOwned<'a, Owned = Self::DiffOwned> where Self: 'a

GAT diff type.

source

type DiffOwned: for<'a> Semigroup<Self::Diff<'a>>

Owned diff type.

Required Methods§

source

fn into_parts(item: Self::Item<'_>) -> (Self::Key<'_>, Self::Diff<'_>)

Deconstruct an item into key and diff. Must be cheap.

source

fn push_with_diff(&mut self, key: Self::Key<'_>, diff: Self::DiffOwned)

Push an element to a compatible container.

This function is odd to have, so let’s explain why it exists. Ideally, the container would accept a (key, diff) pair and we wouldn’t need this function. However, we might never be in a position where this is true: Vectors can push any T, which would collide with a specific implementation for pushing tuples of mixes GATs and owned types.

For this reason, we expose a function here that takes a GAT key and an owned diff, and leave it to the implementation to “patch” a suitable item that can be pushed into self.

source

fn cmp(item1: &Self::Item<'_>, item2: &Self::Item<'_>) -> Ordering

Compare two items by key to sort containers.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<D, T, R> ConsolidateLayout for Vec<(D, T, R)>
where D: Ord + Clone + 'static, T: Ord + Clone + 'static, for<'a> R: Semigroup + IntoOwned<'a, Owned = R> + Clone + 'static,

§

type Key<'a> = (D, T) where Self: 'a

§

type Diff<'a> = R where Self: 'a

§

type DiffOwned = R

source§

fn into_parts( (data, time, diff): Self::Item<'_>, ) -> (Self::Key<'_>, Self::Diff<'_>)

source§

fn cmp<'a>(item1: &Self::Item<'_>, item2: &Self::Item<'_>) -> Ordering

source§

fn push_with_diff(&mut self, (data, time): Self::Key<'_>, diff: Self::DiffOwned)

source§

impl<K, V, T, R> ConsolidateLayout for FlatStack<TupleABCRegion<TupleABRegion<K, V>, T, R>>
where for<'a> K: Region + Push<<K as Region>::ReadItem<'a>> + Clone + 'static, for<'a> K::ReadItem<'a>: Ord + Copy, for<'a> V: Region + Push<<V as Region>::ReadItem<'a>> + Clone + 'static, for<'a> V::ReadItem<'a>: Ord + Copy, for<'a> T: Region + Push<<T as Region>::ReadItem<'a>> + Clone + 'static, for<'a> T::ReadItem<'a>: Ord + Copy, R: Region + Push<<R as Region>::Owned> + Clone + 'static, for<'a> R::Owned: Semigroup<R::ReadItem<'a>>,

§

type Key<'a> = (<K as Region>::ReadItem<'a>, <V as Region>::ReadItem<'a>, <T as Region>::ReadItem<'a>) where Self: 'a

§

type Diff<'a> = <R as Region>::ReadItem<'a> where Self: 'a

§

type DiffOwned = <R as Region>::Owned

source§

fn into_parts( ((key, val), time, diff): Self::Item<'_>, ) -> (Self::Key<'_>, Self::Diff<'_>)

source§

fn cmp<'a>( ((key1, val1), time1, _diff1): &Self::Item<'_>, ((key2, val2), time2, _diff2): &Self::Item<'_>, ) -> Ordering

source§

fn push_with_diff( &mut self, (key, value, time): Self::Key<'_>, diff: Self::DiffOwned, )

Implementors§