Splittable

Trait Splittable 

Source
pub trait Splittable: Sized {
    type Key: 'static + Send + Sync + Eq + Hash + Clone + Debug;
    type Identifier: 'static + Send + Sync;
    type Item: 'static + Send + Sync;

    // Required methods
    fn validate(key: &Self::Key) -> bool;
    fn next(key: &Option<Self::Key>) -> Option<Self::Key>;
    fn split(
        self,
        dispatcher: SplitDispatcher<'_, Self::Key, Self::Identifier, Self::Item>,
    ) -> OperationResult;
}
Expand description

Implementing this trait on a struct will allow the Chain::split operation to be performed on outputs of that type.

Required Associated Types§

Source

type Key: 'static + Send + Sync + Eq + Hash + Clone + Debug

The key used to identify different elements in the split

Source

type Identifier: 'static + Send + Sync

An identifier that will be included along with the item in the messages that are produced by the split. In other words, each message in the split will be a tuple of (Identiifer, Item). You can then choose to map away the identifier if you don’t need it.

This may be different from the key, because a key can represent entire groups of items.

Source

type Item: 'static + Send + Sync

The type that the value gets split into

Required Methods§

Source

fn validate(key: &Self::Key) -> bool

Return true if the key is feasible for this type of split, otherwise return false. Returning false will cause the user to receive a SplitConnectionError::KeyOutOfBounds. This will also cause iterating to cease.

Source

fn next(key: &Option<Self::Key>) -> Option<Self::Key>

Get the next key value that would follow the provided one. If None is passed in then return the first key. If you return None then the connections will stop iterating.

Source

fn split( self, dispatcher: SplitDispatcher<'_, Self::Key, Self::Identifier, Self::Item>, ) -> OperationResult

Split the value into its parts

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.

Implementations on Foreign Types§

Source§

impl<K, V> Splittable for BTreeMap<K, V>
where K: 'static + Send + Sync + Eq + Hash + Clone + Debug, V: 'static + Send + Sync,

Source§

type Key = MapSplitKey<K>

Source§

type Identifier = K

Source§

type Item = V

Source§

fn validate(_: &Self::Key) -> bool

Source§

fn next(key: &Option<Self::Key>) -> Option<Self::Key>

Source§

fn split( self, dispatcher: SplitDispatcher<'_, Self::Key, Self::Identifier, Self::Item>, ) -> OperationResult

Source§

impl<K, V> Splittable for HashMap<K, V>
where K: 'static + Send + Sync + Eq + Hash + Clone + Debug, V: 'static + Send + Sync,

Source§

type Key = MapSplitKey<K>

Source§

type Identifier = K

Source§

type Item = V

Source§

fn validate(_: &Self::Key) -> bool

Source§

fn next(key: &Option<Self::Key>) -> Option<Self::Key>

Source§

fn split( self, dispatcher: SplitDispatcher<'_, Self::Key, Self::Identifier, Self::Item>, ) -> OperationResult

Source§

impl<T: 'static + Send + Sync> Splittable for Vec<T>

Source§

type Key = ListSplitKey

Source§

type Identifier = usize

Source§

type Item = T

Source§

fn validate(_: &Self::Key) -> bool

Source§

fn next(key: &Option<Self::Key>) -> Option<Self::Key>

Source§

fn split( self, dispatcher: SplitDispatcher<'_, Self::Key, Self::Identifier, Self::Item>, ) -> OperationResult

Source§

impl<T: 'static + Send + Sync, const N: usize> Splittable for [T; N]

Source§

type Key = ListSplitKey

Source§

type Identifier = usize

Source§

type Item = T

Source§

fn validate(key: &Self::Key) -> bool

Source§

fn next(key: &Option<Self::Key>) -> Option<Self::Key>

Source§

fn split( self, dispatcher: SplitDispatcher<'_, Self::Key, Self::Identifier, Self::Item>, ) -> OperationResult

Implementors§

Source§

impl Splittable for Value

Source§

impl<K, V, M> Splittable for SplitAsMap<K, V, M>
where K: 'static + Send + Sync + Eq + Hash + Clone + Debug, V: 'static + Send + Sync, M: 'static + Send + Sync + IntoIterator<Item = (K, V)>,

Source§

impl<T> Splittable for SplitAsList<T>
where T: 'static + Send + Sync + IntoIterator, T::Item: 'static + Send + Sync,

Source§

impl<T: 'static + Send + Sync, const N: usize> Splittable for SmallVec<[T; N]>