pub struct Addr<I: Interface> { /* private fields */ }
Expand description
The address of a Service
.
Addresses allow to send messages to a service that implements a corresponding
Interface
as long as the service is running.
Addresses can be freely cloned. When the last clone is dropped, the message channel of the service closes permanently, which signals to the service that it can shut down.
Implementations§
source§impl<I: Interface> Addr<I>
impl<I: Interface> Addr<I>
sourcepub fn send<M>(&self, message: M) -> <I::Response as MessageResponse>::Outputwhere
I: FromMessage<M>,
pub fn send<M>(&self, message: M) -> <I::Response as MessageResponse>::Outputwhere
I: FromMessage<M>,
Sends a message to the service and returns the response.
Depending on the message’s response behavior, this either returns a future resolving to the return value, or does not return anything for fire-and-forget messages. The communication channel with the service is unbounded, so backlogs could occur when sending too many messages.
Sending asynchronous messages can fail with Err(SendError)
if the service has shut down.
The result of asynchronous messages does not have to be awaited. The message will be
delivered and handled regardless:
sourcepub fn recipient<M>(self) -> Recipient<M, I::Response>where
I: FromMessage<M>,
pub fn recipient<M>(self) -> Recipient<M, I::Response>where
I: FromMessage<M>,
Returns a handle that can receive a given message independent of the interface.
See Recipient
for more information and examples.
Trait Implementations§
Auto Trait Implementations§
impl<I> Freeze for Addr<I>
impl<I> RefUnwindSafe for Addr<I>
impl<I> Send for Addr<I>
impl<I> Sync for Addr<I>
impl<I> Unpin for Addr<I>
impl<I> UnwindSafe for Addr<I>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)