pub struct Subscription<T> { /* private fields */ }
Expand description
A Subscription object ties a stream to a listener function such that the listener function is run whenever a new value is added to the stream. When the Subscription object is destroyed the listener function will stop getting called.
§Examples
let stream_host: epoxy_streams::Sink<i32> = epoxy_streams::Sink::new();
let stream = stream_host.get_stream();
{
let _subscription = stream.subscribe(|val| {val;});
assert_eq!(stream.count_subscribers(), 1);
}
assert_eq!(stream.count_subscribers(), 0);
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Subscription<T>
impl<T> RefUnwindSafe for Subscription<T>
impl<T> !Send for Subscription<T>
impl<T> !Sync for Subscription<T>
impl<T> Unpin for Subscription<T>
impl<T> UnwindSafe for Subscription<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