pub struct StableAddr<M: Message> { /* private fields */ }Expand description
A typed capability handle that remains valid across supervisor restarts.
Internally wraps a tokio::sync::watch channel whose value is updated
by the supervisor via an AddrRefresher after each actor (re)spawn.
Callers holding a StableAddr always route to the current incarnation
without needing to obtain a new handle.
§Liveness window
There is a brief window between actor death and the supervisor’s first
refresh() call during which send() and ask() return
Err(SendError::Unroutable). Callers should treat these as transient.
Implementations§
Source§impl<M: Message> StableAddr<M>
impl<M: Message> StableAddr<M>
Sourcepub fn from_receiver(rx: Receiver<Option<Addr<M>>>) -> Self
pub fn from_receiver(rx: Receiver<Option<Addr<M>>>) -> Self
Create a StableAddr from a raw watch receiver.
Called by make_stable_addr in pd-runtime; not intended for direct
use in application code.
Sourcepub fn from_addr(addr: Addr<M>) -> Self
pub fn from_addr(addr: Addr<M>) -> Self
Wrap a plain Addr<M> in a StableAddr that is never refreshed.
The wrapped address is permanently bound to the given incarnation.
Useful when passing a plain address to an API that expects StableAddr.
Sourcepub fn send(&self, msg: M) -> Result<(), SendError>
pub fn send(&self, msg: M) -> Result<(), SendError>
Non-blocking fire-and-forget send to the current incarnation.