[−][src]Struct epoxy_streams::Sink
A Sink is an object used to create a Stream. If you have ever visited a kitchen or bathroom you have probably observed this phenomena already. In more technical terms, Sinks are the 'write' part of functional reactive programming, and Streams are the 'read' part.
Examples
use std::sync::{Arc, Mutex}; let stream_host: epoxy_streams::Sink<i32> = epoxy_streams::Sink::new(); let stream = stream_host.get_stream(); let last_value = Arc::new(Mutex::new(0_i32)); let last_value_write = last_value.clone(); let subscription = stream.subscribe(move |val| { *last_value_write.lock().unwrap() = *val; }); stream_host.emit(1); assert_eq!(*last_value.lock().unwrap(), 1); stream_host.emit(100); assert_eq!(*last_value.lock().unwrap(), 100);
Methods
impl<T> Sink<T>
[src]
pub fn new() -> Sink<T>
[src]
pub fn get_stream(&self) -> Stream<T>
[src]
Returns the Stream that emits values from this Sink. Usually the Stream will be exposed as a public API while the Sink will be kept private, however there are certainly exceptions to this pattern.
pub fn emit(&self, value: T)
[src]
Emits a new value from this Sink, which will broadcast out to any Subscriber to the stream
returned by the get_stream
function.
pub fn emit_rc(&self, value: Arc<T>)
[src]
Same logic as emit
, but takes an existing Arc pointer (Epoxy streams use Arc pointers
internally, so this saves a Copy).
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,