Struct sodium::Router

source ·
pub struct Router<A, K> { /* private fields */ }
Expand description

Create a new Router that routes event items of type A to zero or more Streams of type K according to a given selector function.

Implementations§

source§

impl<A, K> Router<A, K>

source

pub fn new( sodium_ctx: &SodiumCtx, in_stream: &Stream<A>, selector: impl Fn(&A) -> Vec<K> + Send + Sync + 'static ) -> Router<A, K>
where A: Clone + Send + 'static, K: Send + Sync + Eq + Hash + 'static,

Create a new Router from the given input stream and selector function.

source

pub fn filter_matches(&self, k: &K) -> Stream<A>
where A: Clone + Send + 'static, K: Clone + Send + Sync + Eq + Hash + 'static,

Create a Stream that is subscribed to event values that the selector function routes to the given K value.

Auto Trait Implementations§

§

impl<A, K> !RefUnwindSafe for Router<A, K>

§

impl<A, K> Send for Router<A, K>
where A: Send, K: Sync + Send,

§

impl<A, K> Sync for Router<A, K>
where A: Send, K: Sync + Send,

§

impl<A, K> Unpin for Router<A, K>

§

impl<A, K> !UnwindSafe for Router<A, K>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.