[][src]Struct froop::Sink

pub struct Sink<T: 'static> { /* fields omitted */ }

A sink is a producer of events. Created by Stream::sink().

Methods

impl<T> Sink<T>[src]

pub fn stream(&self) -> Stream<T>[src]

Get a stream of events from this sink. One stream instance is created for each call, and they all receive the events from the sink.

let sink = froop::Stream::sink();

let stream1 = sink.stream();
let stream2 = sink.stream();

let coll1 = stream1.collect();
let coll2 = stream1.collect();

sink.update(42);
sink.end();

assert_eq!(coll1.wait(), vec![42]);
assert_eq!(coll2.wait(), vec![42]);

pub fn update(&self, next: T)[src]

Update a value into this sink.

The execution of the combinators "hanging" off this sink is (thread safe) and synchronous. In other words, there is nothing in froop itself that will still be "to do" once the update() call returns.

Each value is wrapped in an Option towards subscribers of the streams.

let sink = froop::Stream::sink();
let stream = sink.stream();

stream.subscribe(|v| {
    // v is Some(0), Some(1), None
});

sink.update(0);
sink.update(1);
sink.end();

pub fn end(self)[src]

End the stream of events. Consumes the instance since no more values are to go into it.

Subscribers will se a None value.

Every stream hanging directly off this sink will also end. The exception is streams combining input from multiple source streams.

Auto Trait Implementations

impl<T> Send for Sink<T> where
    T: Send

impl<T> Sync for Sink<T> where
    T: Send

Blanket Implementations

impl<T> From for T[src]

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

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.