Struct calloop::LoopHandle[][src]

pub struct LoopHandle<'l, Data> { /* fields omitted */ }

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

impl<'l, Data> LoopHandle<'l, Data>[src]

pub fn insert_source<S, F>(
    &self,
    source: S,
    callback: F
) -> Result<RegistrationToken, InsertError<S>> where
    S: EventSource + 'l,
    F: FnMut(S::Event, &mut S::Metadata, &mut Data) -> S::Ret + 'l, 
[src]

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.

pub fn register_dispatcher<S, F>(
    &self,
    dispatcher: Dispatcher<S, F>
) -> Result<RegistrationToken> where
    S: EventSource + 'l,
    F: FnMut(S::Event, &mut S::Metadata, &mut Data) -> S::Ret + 'l, 
[src]

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.

pub fn insert_idle<F: FnOnce(&mut Data) + 'l>(&self, callback: F) -> Idle<'_>[src]

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.

pub fn enable(&self, token: &RegistrationToken) -> Result<()>[src]

Enables this previously disabled event source.

This previously disabled source will start generating events again.

Note: This cannot be done from within the callback of the same source.

pub fn update(&self, token: &RegistrationToken) -> Result<()>[src]

Makes this source update its registration.

If after accessing the source you changed its parameters in a way that requires updating its registration.

Note: This cannot be done from within the callback of the same source.

pub fn disable(&self, token: &RegistrationToken) -> Result<()>[src]

Disables this event source.

The source remains in the event loop, but it'll no longer generate events

Note: This cannot be done from within the callback of the same source.

pub fn remove(&self, token: RegistrationToken)[src]

Removes this source from the event loop.

Note: This cannot be done from within the callback of the same source.

pub fn kill(&self, token: RegistrationToken)[src]

Removes this source from the event loop.

Note: This can be done from within the callback of the same source.

pub fn adapt_io<F: AsRawFd>(&self, fd: F) -> Result<Async<'l, F>>[src]

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

impl<'l, Data> Clone for LoopHandle<'l, Data>[src]

Auto Trait Implementations

impl<'l, Data> !RefUnwindSafe for LoopHandle<'l, Data>[src]

impl<'l, Data> !Send for LoopHandle<'l, Data>[src]

impl<'l, Data> !Sync for LoopHandle<'l, Data>[src]

impl<'l, Data> Unpin for LoopHandle<'l, Data>[src]

impl<'l, Data> !UnwindSafe for LoopHandle<'l, Data>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.