Struct multi_consumer_stream::OwnerMCS [] [src]

pub struct OwnerMCS<S: Stream, K, F>(_);

A wrapper around a stream, that allows obtaining multiple handles for reading from that stream.

A KeyHandle only receives items for which the key_fn returns a certain key. All other items are emitted on a DefaultHandle.

Methods

impl<S, K, F> OwnerMCS<S, K, F> where
    S: Stream,
    K: Copy + Eq + Hash,
    F: Fn(&S::Item) -> K, 
[src]

[src]

Create a new OwnerMCS, wrapping stream.

The key_fn is invoked for each item emitted by the stream. Its return value is used to give the item to the correct handle. If the return value does not match the key of any handle, the item is emitted on a DefaultHandle.

[src]

Create a KeyHandle to the underlying stream. The handle receives all items for which the key_fn returns key.

Panics if there is already a handle for that key.

[src]

Create a KeyHandle to the underlying stream. The handle receives all items for which the key_fn returns key. This returns None if there is already a handle for the given key.

[src]

Create a DefaultHandle to the underlying stream. The handle receives all items for which there is no KeyHandle.

The behaviour of multiple DefaultHandles polling at the same time is safe, but unspecified. Just don't do that.