Struct calloop::Dispatcher

source ·
pub struct Dispatcher<'a, S, Data>(_);
Expand description

An event source with its callback.

The Dispatcher can be registered in an event loop. Use the as_source_{ref,mut} functions to interact with the event source. Use into_source_inner to get the event source back.

Implementations§

source§

impl<'a, S, Data> Dispatcher<'a, S, Data>where S: EventSource + 'a,

source

pub fn new<F>(source: S, callback: F) -> Selfwhere F: FnMut(S::Event, &mut S::Metadata, &mut Data) -> S::Ret + 'a,

Builds a dispatcher.

The resulting Dispatcher

source

pub fn as_source_ref(&self) -> Ref<'_, S>

Returns an immutable reference to the event source.

Panics

Has the same semantics as RefCell::borrow().

The dispatcher being mutably borrowed while its events are dispatched, this method will panic if invoked from within the associated dispatching closure.

source

pub fn as_source_mut(&self) -> RefMut<'_, S>

Returns a mutable reference to the event source.

Panics

Has the same semantics as RefCell::borrow_mut().

The dispatcher being mutably borrowed while its events are dispatched, this method will panic if invoked from within the associated dispatching closure.

source

pub fn into_source_inner(self) -> S

Consumes the Dispatcher and returns the inner event source.

Panics

Panics if the Dispatcher is still registered.

Trait Implementations§

source§

impl<'a, S, Data> Clone for Dispatcher<'a, S, Data>

source§

fn clone(&self) -> Dispatcher<'a, S, Data>

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<'a, S, Data> Debug for Dispatcher<'a, S, Data>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, S, Data> !RefUnwindSafe for Dispatcher<'a, S, Data>

§

impl<'a, S, Data> !Send for Dispatcher<'a, S, Data>

§

impl<'a, S, Data> !Sync for Dispatcher<'a, S, Data>

§

impl<'a, S, Data> Unpin for Dispatcher<'a, S, Data>

§

impl<'a, S, Data> !UnwindSafe for Dispatcher<'a, S, Data>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.