Struct calloop::sources::Dispatcher

source ·
pub struct Dispatcher<'a, S, Data>(Rc<dyn ErasedDispatcher<'a, S, Data> + 'a>);
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.

Tuple Fields§

§0: Rc<dyn ErasedDispatcher<'a, S, Data> + 'a>

Implementations§

source§

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

source

pub fn new<F>(source: S, callback: F) -> Self
where 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.

source

pub(crate) fn clone_as_event_dispatcher( &self, ) -> Rc<dyn EventDispatcher<Data> + 'a>

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

§

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 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