Struct event_source::EventSource
source · pub struct EventSource<T: ForLifetime> { /* private fields */ }Expand description
Event source
Implementations§
source§impl<T: ForLifetime> EventSource<T>
impl<T: ForLifetime> EventSource<T>
sourcepub const fn new() -> Self
pub const fn new() -> Self
Create new EventSource
sourcepub fn with_emitter(&self, emit_fn: impl FnOnce(EventEmitter<'_, T>))
pub fn with_emitter(&self, emit_fn: impl FnOnce(EventEmitter<'_, T>))
Create EventEmitter for this EventSource
sourcepub fn on<F>(&self, listener: F) -> EventFnFuture<'_, F, T> ⓘwhere
F: FnMut(T::Of<'_>, &mut ControlFlow) + Send + Sync,
pub fn on<F>(&self, listener: F) -> EventFnFuture<'_, F, T> ⓘwhere F: FnMut(T::Of<'_>, &mut ControlFlow) + Send + Sync,
Listen events
It can be called after woken if another event occurred before task continue
sourcepub async fn once<F, R>(&self, listener: F) -> Option<R>where
F: FnMut(T::Of<'_>, &mut ControlFlow) -> Option<R> + Send + Sync,
R: Send + Sync,
pub async fn once<F, R>(&self, listener: F) -> Option<R>where F: FnMut(T::Of<'_>, &mut ControlFlow) -> Option<R> + Send + Sync, R: Send + Sync,
Listen event until listener returns Option::Some
Unlike EventSource::on it will ignore every events once listener is done or returns with Option::Some.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for EventSource<T>
impl<T> Send for EventSource<T>
impl<T> Sync for EventSource<T>
impl<T> Unpin for EventSource<T>
impl<T> !UnwindSafe for EventSource<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