pub struct Receiver { /* private fields */ }Expand description
One async callback for one signal of one model.
Usually produced by #[receiver(..)]; build one by hand with
Receiver::new.
Implementations§
Source§impl Receiver
impl Receiver
Sourcepub fn new<M, F>(name: SignalName, handler: F) -> Selfwhere
M: Model,
F: for<'a> Fn(&'a M, &'a SignalEvent<'a>) -> BoxFuture<'a, Result<(), SignalError>> + Send + Sync + 'static,
pub fn new<M, F>(name: SignalName, handler: F) -> Selfwhere
M: Model,
F: for<'a> Fn(&'a M, &'a SignalEvent<'a>) -> BoxFuture<'a, Result<(), SignalError>> + Send + Sync + 'static,
A receiver for signal name of model M.
handler gets the instance as &M; the downcast is checked, so a
receiver never sees another model.
ⓘ
Receiver::new::<User, _>(SignalName::PostSave, |user, event| {
Box::pin(async move { Ok(()) })
})Sourcepub fn name(&self) -> SignalName
pub fn name(&self) -> SignalName
The signal this receiver listens to.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Receiver
impl !UnwindSafe for Receiver
impl Freeze for Receiver
impl Send for Receiver
impl Sync for Receiver
impl Unpin for Receiver
impl UnsafeUnpin for Receiver
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