Struct calloop::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,
impl<'a, S, Data> Dispatcher<'a, S, Data>where
S: EventSource + 'a,
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.
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>
impl<'a, S, Data> Clone for Dispatcher<'a, S, Data>
source§fn clone(&self) -> Dispatcher<'a, S, Data>
fn clone(&self) -> Dispatcher<'a, S, Data>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more