pub struct Signaler<S> { /* private fields */ }
Expand description
A signaler, main type for signaling
Implementations§
Source§impl<S> Signaler<S>
impl<S> Signaler<S>
Sourcepub fn register<F: FnMut(&S) + 'static>(&self, f: F) -> SignalToken
pub fn register<F: FnMut(&S) + 'static>(&self, f: F) -> SignalToken
Register a new callback to this signaler
This method returns a SignalToken
, which you must keep as long
as you need your callback to remain in place. Dropping it will
disable and free your callback. If you don’t plan to ever disable
your callback, see SignalToken::leak()
.
If you register a callback from within a callback of the same Signaler, the new callback will only be inserted after the current signal is completely delivered, and thus will not receive it.
Sourcepub fn signal(&self, signal: S)
pub fn signal(&self, signal: S)
Signal the callbacks
All registered callbacks will be invoked with a reference to the value you provide here, after which that value will be dropped.
If this method is invoked from within a callback of the same Signaler, its signalling will be delayed until the current signal is completely delivered and this method will return immediately.
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for Signaler<S>
impl<S> !RefUnwindSafe for Signaler<S>
impl<S> !Send for Signaler<S>
impl<S> !Sync for Signaler<S>
impl<S> Unpin for Signaler<S>
impl<S> !UnwindSafe for Signaler<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.