Skip to main content

guinea_core/actor/
traits.rs

1use crate::actor::Cx;
2use crate::actor::event_bus::builder::EventSubscription;
3
4pub trait Handler<M: 'static>: 'static {
5    /// Where the handler was written; `#[handler]` fills it in.
6    const DECLARED: Option<crate::actor::shape::Declared> = None;
7
8    /// Whether handling `M` answers it: set for a request's handler, the one
9    /// that returns the reply. A bus lets one subscriber answer each request
10    /// type; the rest only hear it.
11    const ANSWERS: bool = false;
12
13    fn handle(&mut self, msg: M, cx: Cx<Self, M>)
14    where
15        Self: Sized;
16}
17
18pub trait ManagedActor: Sized + 'static {
19    type Bus: EventSubscription<Self>;
20    type Signals;
21    /// Declared outgoing messages per handler, or `Open` when undeclared.
22    type Flow;
23    /// What `actor!` declared, for devtools.
24    const SHAPE: crate::actor::shape::Shape = crate::actor::shape::Shape::UNKNOWN;
25}
26
27pub trait AllowedSignal<M: 'static> {}
28impl<M: 'static> AllowedSignal<M> for M {}