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
sourceimpl<'a, S, Data> Dispatcher<'a, S, Data> where
S: EventSource + 'a,
impl<'a, S, Data> Dispatcher<'a, S, Data> where
S: EventSource + 'a,
sourcepub fn new<F>(source: S, callback: F) -> Self where
F: FnMut(S::Event, &mut S::Metadata, &mut Data) -> S::Ret + 'a,
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
sourcepub fn as_source_ref(&self) -> Ref<'_, S>
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.
sourcepub fn as_source_mut(&self) -> RefMut<'_, S>
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.
sourcepub fn into_source_inner(self) -> S
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
sourceimpl<'a, S, Data> Clone for Dispatcher<'a, S, Data>
impl<'a, S, Data> Clone for Dispatcher<'a, S, Data>
sourcefn clone(&self) -> Dispatcher<'a, S, Data>
fn clone(&self) -> Dispatcher<'a, S, Data>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more