pub struct Addr<M: Message> { /* private fields */ }Expand description
A typed, unforgeable capability handle granting the right to send messages
of type M to a specific actor.
Cannot be constructed by user code — only the runtime grants Addr<M>
instances (at spawn time or via supervisor delegation).
Implementations§
Source§impl<M: Message> Addr<M>
impl<M: Message> Addr<M>
Sourcepub fn with_handlers(
target: AddrHash,
send_fn: SendFn<M>,
ask_fn: AskFn<M>,
) -> Self
pub fn with_handlers( target: AddrHash, send_fn: SendFn<M>, ask_fn: AskFn<M>, ) -> Self
Create a typed capability handle with send and ask backends.
Called by the runtime when spawning actors; not intended for direct use in application code.
Sourcepub fn unbound(target: AddrHash) -> Self
pub fn unbound(target: AddrHash) -> Self
Create an unbound handle (no send/ask backend). Useful for holding an address reference before the actor is live.
pub fn target(&self) -> AddrHash
Sourcepub fn send(&self, msg: M) -> Result<(), SendError>
pub fn send(&self, msg: M) -> Result<(), SendError>
Non-blocking fire-and-forget send. Returns SendError::MailboxFull
immediately if the mailbox is at capacity.
Sourcepub async fn ask(&self, msg: M) -> Result<M::Response, AskError>
pub async fn ask(&self, msg: M) -> Result<M::Response, AskError>
Request/response send. Returns a future that resolves to the response.
pub fn downgrade(&self) -> WeakAddr<M>
Trait Implementations§
Auto Trait Implementations§
impl<M> Freeze for Addr<M>
impl<M> !RefUnwindSafe for Addr<M>
impl<M> Send for Addr<M>
impl<M> Sync for Addr<M>
impl<M> Unpin for Addr<M>
impl<M> UnsafeUnpin for Addr<M>
impl<M> !UnwindSafe for Addr<M>
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