Struct zng::event::EventReceiver
source · pub struct EventReceiver<A>{ /* private fields */ }
Expand description
An event channel receiver.
Use Event::receiver
to create a receiver, drop to stop listening.
Implementations§
source§impl<A> EventReceiver<A>
impl<A> EventReceiver<A>
sourcepub fn recv(&self) -> Result<A, AppDisconnected<()>>
pub fn recv(&self) -> Result<A, AppDisconnected<()>>
Receives the oldest update, blocks until the event updates.
Note that oldest here refers to send order (FIFO), not the args creation timestamp.
sourcepub fn try_recv(&self) -> Result<A, Option<AppDisconnected<()>>>
pub fn try_recv(&self) -> Result<A, Option<AppDisconnected<()>>>
Tries to receive the oldest sent update not received, returns Ok(args)
if there was at least
one update, or returns Err(None)
if there was no update or returns Err(AppDisconnected)
if the connected
app has exited.
sourcepub fn recv_deadline(
&self,
deadline: Instant,
) -> Result<A, TimeoutOrAppDisconnected>
pub fn recv_deadline( &self, deadline: Instant, ) -> Result<A, TimeoutOrAppDisconnected>
Receives the oldest send update, blocks until the event updates or until the deadline
is reached.
sourcepub fn recv_timeout(&self, dur: Duration) -> Result<A, TimeoutOrAppDisconnected>
pub fn recv_timeout(&self, dur: Duration) -> Result<A, TimeoutOrAppDisconnected>
Receives the oldest send update, blocks until the event updates or until timeout.
sourcepub async fn recv_async(&self) -> Result<A, AppDisconnected<()>>
pub async fn recv_async(&self) -> Result<A, AppDisconnected<()>>
Returns a future that receives the oldest send update, awaits until an event update occurs.
sourcepub fn into_recv_async(
self,
) -> impl Future<Output = Result<A, AppDisconnected<()>>> + Send + Sync + 'static
pub fn into_recv_async( self, ) -> impl Future<Output = Result<A, AppDisconnected<()>>> + Send + Sync + 'static
Turns into a future that receives the oldest send update, awaits until an event update occurs.
sourcepub fn iter(&self) -> Iter<'_, A>
pub fn iter(&self) -> Iter<'_, A>
Creates a blocking iterator over event updates, if there are no updates sent the iterator blocks, the iterator only finishes when the app shuts-down.
Trait Implementations§
source§impl<A> Clone for EventReceiver<A>
impl<A> Clone for EventReceiver<A>
source§fn clone(&self) -> EventReceiver<A>
fn clone(&self) -> EventReceiver<A>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<A> Debug for EventReceiver<A>
impl<A> Debug for EventReceiver<A>
source§impl<'a, A> IntoIterator for &'a EventReceiver<A>
impl<'a, A> IntoIterator for &'a EventReceiver<A>
source§impl<A> IntoIterator for EventReceiver<A>
impl<A> IntoIterator for EventReceiver<A>
Auto Trait Implementations§
impl<A> Freeze for EventReceiver<A>
impl<A> RefUnwindSafe for EventReceiver<A>
impl<A> Send for EventReceiver<A>
impl<A> Sync for EventReceiver<A>
impl<A> Unpin for EventReceiver<A>
impl<A> UnwindSafe for EventReceiver<A>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more