Struct calloop::LoopHandle
source · pub struct LoopHandle<'l, Data> { /* private fields */ }
Expand description
An handle to an event loop
This handle allows you to insert new sources and idles in this event loop, it can be cloned, and it is possible to insert new sources from within a source callback.
Implementations§
source§impl<'l, Data> LoopHandle<'l, Data>
impl<'l, Data> LoopHandle<'l, Data>
sourcepub fn insert_source<S, F>(
&self,
source: S,
callback: F,
) -> Result<RegistrationToken, InsertError<S>>
pub fn insert_source<S, F>( &self, source: S, callback: F, ) -> Result<RegistrationToken, InsertError<S>>
Inserts a new event source in the loop.
The provided callback will be called during the dispatching cycles whenever the
associated source generates events, see EventLoop::dispatch(..)
for details.
This function takes ownership of the event source. Use register_dispatcher
if you need access to the event source after this call.
sourcepub fn register_dispatcher<S>(
&self,
dispatcher: Dispatcher<'l, S, Data>,
) -> Result<RegistrationToken>where
S: EventSource + 'l,
pub fn register_dispatcher<S>(
&self,
dispatcher: Dispatcher<'l, S, Data>,
) -> Result<RegistrationToken>where
S: EventSource + 'l,
Registers a Dispatcher
in the loop.
Use this function if you need access to the event source after its insertion in the loop.
See also insert_source
.
sourcepub fn insert_idle<'i, F: FnOnce(&mut Data) + 'l + 'i>(
&self,
callback: F,
) -> Idle<'i>
pub fn insert_idle<'i, F: FnOnce(&mut Data) + 'l + 'i>( &self, callback: F, ) -> Idle<'i>
Inserts an idle callback.
This callback will be called during a dispatching cycle when the event loop has finished processing all pending events from the sources and becomes idle.
sourcepub fn enable(&self, token: &RegistrationToken) -> Result<()>
pub fn enable(&self, token: &RegistrationToken) -> Result<()>
Enables this previously disabled event source.
This previously disabled source will start generating events again.
Note: this cannot be done from within the source callback.
sourcepub fn update(&self, token: &RegistrationToken) -> Result<()>
pub fn update(&self, token: &RegistrationToken) -> Result<()>
Makes this source update its registration.
If after accessing the source you changed its parameters in a way that requires updating its registration.
sourcepub fn disable(&self, token: &RegistrationToken) -> Result<()>
pub fn disable(&self, token: &RegistrationToken) -> Result<()>
Disables this event source.
The source remains in the event loop, but it’ll no longer generate events
sourcepub fn remove(&self, token: RegistrationToken)
pub fn remove(&self, token: RegistrationToken)
Removes this source from the event loop.
sourcepub fn adapt_io<F: AsFd>(&self, fd: F) -> Result<Async<'l, F>>
pub fn adapt_io<F: AsFd>(&self, fd: F) -> Result<Async<'l, F>>
Wrap an IO object into an async adapter
This adapter turns the IO object into an async-aware one that can be used in futures. The readiness of these futures will be driven by the event loop.
The produced futures can be polled in any executor, and notably the one provided by calloop.
Trait Implementations§
source§impl<'l, Data> Clone for LoopHandle<'l, Data>
impl<'l, Data> Clone for LoopHandle<'l, Data>
Auto Trait Implementations§
impl<'l, Data> Freeze for LoopHandle<'l, Data>
impl<'l, Data> !RefUnwindSafe for LoopHandle<'l, Data>
impl<'l, Data> !Send for LoopHandle<'l, Data>
impl<'l, Data> !Sync for LoopHandle<'l, Data>
impl<'l, Data> Unpin for LoopHandle<'l, Data>
impl<'l, Data> !UnwindSafe for LoopHandle<'l, Data>
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
)