Struct zng_app::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§impl<A> Debug for EventReceiver<A>
impl<A> Debug for EventReceiver<A>
source§impl<A> From<EventReceiver<A>> for Receiver<A>
impl<A> From<EventReceiver<A>> for Receiver<A>
source§fn from(e: EventReceiver<A>) -> Self
fn from(e: EventReceiver<A>) -> Self
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> 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> 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