pub struct Sink<T: 'static> { /* private fields */ }
Expand description
A sink is a producer of events. Created by Stream::sink()
.
Implementations§
Source§impl<T> Sink<T>
impl<T> Sink<T>
Sourcepub fn stream(&self) -> Stream<T>
pub fn stream(&self) -> Stream<T>
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]);
Sourcepub fn update(&self, next: T)
pub fn update(&self, next: T)
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();
Auto Trait Implementations§
impl<T> Freeze for Sink<T>
impl<T> RefUnwindSafe for Sink<T>
impl<T> Send for Sink<T>where
T: Send,
impl<T> Sync for Sink<T>where
T: Send,
impl<T> Unpin for Sink<T>
impl<T> UnwindSafe for Sink<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more