pub struct Signal<M> { /* private fields */ }
Expand description
A source that emits a message once a signal is received. Clones the message on every tick.
It’s based on the tokio implementation, so it should be useful to read about caveats.
Tracing
Every message starts a new trace, thus a new trace id is generated and assigned to the current scope.
Example
use elfo::signal::{Signal, SignalKind};
#[message]
struct ReloadFile;
ctx.attach(Signal::new(SignalKind::UnixHangup, ReloadFile));
while let Some(envelope) = ctx.recv().await {
msg!(match envelope {
ReloadFile => { /* ... */ },
});
}
Implementations§
source§impl<M> Signal<M>where
M: Message,
impl<M> Signal<M>where M: Message,
sourcepub fn new(kind: SignalKind, message: M) -> UnattachedSource<Signal<M>>
pub fn new(kind: SignalKind, message: M) -> UnattachedSource<Signal<M>>
Creates an unattached instance of Signal
.
sourcepub fn set_message(&self, message: M)
pub fn set_message(&self, message: M)
Replaces a stored message with the provided one.
Trait Implementations§
Auto Trait Implementations§
impl<M> !RefUnwindSafe for Signal<M>
impl<M> Send for Signal<M>where M: Send,
impl<M> Sync for Signal<M>where M: Sync,
impl<M> Unpin for Signal<M>
impl<M> !UnwindSafe for Signal<M>
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
Mutably borrows from an owned value. Read more