Struct multi_consumer_stream::MCS
[−]
[src]
pub struct MCS<S: Stream, Key: Eq + Hash + Copy, ItemFn, ErrFn>(_);
Wraps a stream and provides a multi-consumer-stream.
This structs allows to create new MCSHandle, which receive all the items/errors for which
the ItemFn/ErrFn compute a certain key. All items/errors for which no corresponding
MCSHandle exist are routed to the primary MCS.
Methods
impl<S, Key, ItemFn, ErrFn> MCS<S, Key, ItemFn, ErrFn> where
S: Stream,
Key: Eq + Hash + Copy, [src]
S: Stream,
Key: Eq + Hash + Copy,
pub fn new(
stream: S,
item_fn: ItemFn,
err_fn: ErrFn
) -> MCS<S, Key, ItemFn, ErrFn>[src]
stream: S,
item_fn: ItemFn,
err_fn: ErrFn
) -> MCS<S, Key, ItemFn, ErrFn>
Create a new MCS with the given functions to compute keys.
impl<S, Key, ItemFn, ErrFn> MCS<S, Key, ItemFn, ErrFn> where
S: Stream,
Key: Eq + Hash + Copy,
ItemFn: Fn(&S::Item) -> Key,
ErrFn: Fn(&S::Error) -> Key, [src]
S: Stream,
Key: Eq + Hash + Copy,
ItemFn: Fn(&S::Item) -> Key,
ErrFn: Fn(&S::Error) -> Key,
pub fn into_inner(self) -> S[src]
Consume the MCS and retrieve ownership of the wrapped stream.
Polling an MCSHandle after consuming its MCS panics.
pub fn mcs_handle(&self, key: Key) -> MCSHandle<S, Key, ItemFn, ErrFn>[src]
Create a MCSHandle to the underlying stream. The handle receives all items for which the
MCS's item_fn returns key, and all errors for which the MCS's error_fn returns
key.
Panics if there is already a handle for that key.
pub fn try_mcs_handle(
&self,
key: Key
) -> Option<MCSHandle<S, Key, ItemFn, ErrFn>>[src]
&self,
key: Key
) -> Option<MCSHandle<S, Key, ItemFn, ErrFn>>
Create a MCSHandle to the underlying stream. The handle receives all items for which the
MCS's item_fn returns key, and all errors for which the MCS's error_fn returns
key.
This returns None if there is already a handle for that key.
Trait Implementations
impl<S, Key, ItemFn, ErrFn> Stream for MCS<S, Key, ItemFn, ErrFn> where
S: Stream,
Key: Copy + Eq + Hash,
ItemFn: Fn(&S::Item) -> Key,
ErrFn: Fn(&S::Error) -> Key, [src]
S: Stream,
Key: Copy + Eq + Hash,
ItemFn: Fn(&S::Item) -> Key,
ErrFn: Fn(&S::Error) -> Key,
type Item = S::Item
Values yielded by the stream.
type Error = S::Error
Errors yielded by the stream.
fn poll_next(
&mut self,
cx: &mut Context
) -> Poll<Option<Self::Item>, Self::Error>[src]
&mut self,
cx: &mut Context
) -> Poll<Option<Self::Item>, Self::Error>
Attempt to pull out the next value of this stream, registering the current task for wakeup if the value is not yet available, and returning None if the stream is exhausted. Read more