pub struct EventLoopHandle { /* private fields */ }Expand description
Handle for registering custom event sources with the event loop
Supports timers, channels, file descriptors, and custom event sources.
Implementations§
Source§impl EventLoopHandle
impl EventLoopHandle
pub fn new(system: Weak<RefCell<dyn WaylandSystemOps>>) -> EventLoopHandle
Sourcepub fn insert_source<S, F, R>(
&self,
source: S,
callback: F,
) -> Result<RegistrationToken, Error>where
S: EventSource<Ret = R> + 'static,
F: FnMut(<S as EventSource>::Event, &mut <S as EventSource>::Metadata, &mut AppState) -> R + 'static,
pub fn insert_source<S, F, R>(
&self,
source: S,
callback: F,
) -> Result<RegistrationToken, Error>where
S: EventSource<Ret = R> + 'static,
F: FnMut(<S as EventSource>::Event, &mut <S as EventSource>::Metadata, &mut AppState) -> R + 'static,
Register a custom event source with the event loop
Returns a registration token that can be used to remove the source later.
Sourcepub fn add_timer<F>(
&self,
duration: Duration,
callback: F,
) -> Result<RegistrationToken, Error>
pub fn add_timer<F>( &self, duration: Duration, callback: F, ) -> Result<RegistrationToken, Error>
Add a timer that fires after the specified duration
Return TimeoutAction::Drop for one-shot, ToDuration(d) to repeat, or ToInstant(i) for next deadline.
Sourcepub fn add_timer_at<F>(
&self,
deadline: Instant,
callback: F,
) -> Result<RegistrationToken, Error>
pub fn add_timer_at<F>( &self, deadline: Instant, callback: F, ) -> Result<RegistrationToken, Error>
Add a timer that fires at a specific instant
Callback receives the deadline and can return TimeoutAction::ToInstant to reschedule.
Sourcepub fn add_channel<T, F>(
&self,
callback: F,
) -> Result<(RegistrationToken, Sender<T>), Error>
pub fn add_channel<T, F>( &self, callback: F, ) -> Result<(RegistrationToken, Sender<T>), Error>
Add a channel for sending messages to the event loop from any thread
The sender can be cloned and sent across threads. Messages are queued and processed on the main thread.
Auto Trait Implementations§
impl Freeze for EventLoopHandle
impl !RefUnwindSafe for EventLoopHandle
impl !Send for EventLoopHandle
impl !Sync for EventLoopHandle
impl Unpin for EventLoopHandle
impl !UnwindSafe for EventLoopHandle
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.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>
Converts
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>
Converts
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