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;
use std::sync::Arc;
// addr.send(Message::Put(put)) — wraps in Arc internally
// addr.send(Arc::clone(&msg)) — refcount bump, no allocation
// Err(()) means the actor's mailbox is closed (actor stopped)Implementations§
Source§impl Addr
impl Addr
Sourcepub fn new(sender: MailboxSender) -> Self
pub fn new(sender: MailboxSender) -> Self
Creates a new address wrapping a MailboxSender.
Sourcepub fn send(&self, msg: impl Into<Arc<Message>>) -> Result<(), ()>
pub fn send(&self, msg: impl Into<Arc<Message>>) -> Result<(), ()>
Sends a message to this actor.
Accepts impl Into<Arc<Message>> so callers can pass either:
Message::Put(put)— wrapped inArcinternally (one allocation)Arc::clone(&msg)— refcount bump, zero allocation (for fanout)
Returns Ok(()) if the message was enqueued, Err(()) if the
mailbox is full (backpressure) or closed (actor stopped).
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 !RefUnwindSafe for Addr
impl !UnwindSafe for Addr
impl Freeze for Addr
impl Send for Addr
impl Sync for Addr
impl Unpin for Addr
impl UnsafeUnpin 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
Mutably borrows from an owned value. Read more
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.