Struct calloop::loop_logic::LoopHandle

source ·
pub struct LoopHandle<'l, Data> {
    inner: Rc<LoopInner<'l, Data>>,
}
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.

Fields§

§inner: Rc<LoopInner<'l, Data>>

Implementations§

source§

impl<'l, Data> LoopHandle<'l, Data>

source

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,

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.

source

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.

source

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.

source

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.

source

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.

source

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

source

pub fn remove(&self, token: RegistrationToken)

Removes this source from the event loop.

source

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>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'l, Data> Debug for LoopHandle<'l, Data>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more