pub struct Addr { /* private fields */ }Expand description
A clonable, hashable address for sending messages to an actor.
Addr implements PartialEq, Eq, and Hash based on its id field
(a random 32-character string), not the underlying channel sender.
This means two Addrs are equal iff they refer to the same actor.
§Sending Messages
use beam::actor::Addr;
use beam::message::Message;
// addr.send(msg) returns Result<(), ()>
// Err(()) means the actor's channel is closed (actor stopped)Implementations§
Source§impl Addr
impl Addr
Sourcepub fn new(sender: UnboundedSender<Message>) -> Self
pub fn new(sender: UnboundedSender<Message>) -> Self
Creates a new address wrapping an unbounded channel sender.
Sourcepub fn new_bounded(sender: Sender<Message>) -> Self
pub fn new_bounded(sender: Sender<Message>) -> Self
Creates a new address wrapping a bounded channel sender.
Bounded addresses apply backpressure: when the channel is full,
send returns Err(()) (same error as a closed channel).
Sourcepub fn send(&self, msg: Message) -> Result<(), ()>
pub fn send(&self, msg: Message) -> Result<(), ()>
Sends a message to this actor.
Returns Ok(()) if the message was enqueued, Err(()) if the
actor’s channel is closed (actor has stopped) or — for bounded
channels — if the channel is full (backpressure).
Callers that must not lose messages should retry on Err. The
Router’s storage dispatch uses let _ = addr.send(...) and accepts
occasional drops under extreme backpressure, which is the correct
trade-off for an LWW graph store.
Trait Implementations§
impl Eq for Addr
Auto Trait Implementations§
impl Freeze for Addr
impl RefUnwindSafe for Addr
impl Send for Addr
impl Sync for Addr
impl Unpin for Addr
impl UnsafeUnpin for Addr
impl UnwindSafe for Addr
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.