[][src]Struct stream_map_any::StreamMapAny

pub struct StreamMapAny<K> { /* fields omitted */ }

Combines streams with different output types into one.

Methods

impl<K> StreamMapAny<K>[src]

pub const fn new() -> Self[src]

pub fn insert<S>(&mut self, key: K, stream: S) where
    S: Stream + Unpin + 'static,
    S::Item: Any,
    K: Eq
[src]

Insert a new stream into the map with a given key.

If that key is already in use by another stream, that stream will get dropped.

Examples

use futures::stream;
use stream_map_any::StreamMapAny;

let mut map = StreamMapAny::new();

map.insert("foo", stream::iter(vec![1]));

pub fn remove<Q>(&mut self, k: &Q) where
    K: Borrow<Q>,
    Q: Eq
[src]

Remove a stream from the map with a given key.

The stream will get dropped.

Examples

use futures::stream;
use stream_map_any::StreamMapAny;

let mut map = StreamMapAny::new();

map.insert(1, stream::iter(vec![1]));
assert_eq!(map.contains_key(&1), true);

map.remove(&1);
assert_eq!(map.contains_key(&1), false);

pub fn contains_key<Q>(&self, k: &Q) -> bool where
    K: Borrow<Q>,
    Q: Eq
[src]

Returns true if the map contains a stream for the specified key.

Examples

use futures::stream;
use stream_map_any::StreamMapAny;

let mut map = StreamMapAny::new();

map.insert(1, stream::iter(vec![1]));
assert_eq!(map.contains_key(&1), true);
assert_eq!(map.contains_key(&2), false);

Trait Implementations

impl<K> Stream for StreamMapAny<K> where
    K: Unpin + Clone
[src]

type Item = (K, StreamMapAnyVariant)

Values yielded by the stream.

Auto Trait Implementations

impl<K> !RefUnwindSafe for StreamMapAny<K>

impl<K> !Send for StreamMapAny<K>

impl<K> !Sync for StreamMapAny<K>

impl<K> Unpin for StreamMapAny<K> where
    K: Unpin

impl<K> !UnwindSafe for StreamMapAny<K>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StreamExt for T where
    T: Stream + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.