pub struct WithRecipient<Req, Resp>where
Req: MessageBounds,
Resp: Debug + 'static,{ /* private fields */ }Expand description
A generic type for request-response messages with a Recipient as actor reference
This type contains narrowed information about the target actor for the response, as well as the actual request itself.
Implementations can also be dereferenced to the request message and replied to with a response.
Implementations§
Source§impl<Req, Resp> WithRecipient<Req, Resp>where
Req: MessageBounds,
Resp: Debug + 'static,
impl<Req, Resp> WithRecipient<Req, Resp>where
Req: MessageBounds,
Resp: Debug + 'static,
Sourcepub fn new(content: Req, sender: Recipient<Resp>) -> WithRecipient<Req, Resp>
pub fn new(content: Req, sender: Recipient<Resp>) -> WithRecipient<Req, Resp>
Create a new instance from a request and a recipient for the response
Sourcepub fn from<M>(
content: Req,
sender: &dyn ActorRefFactory<Message = M>,
) -> WithRecipient<Req, Resp>where
M: MessageBounds + From<Resp>,
pub fn from<M>(
content: Req,
sender: &dyn ActorRefFactory<Message = M>,
) -> WithRecipient<Req, Resp>where
M: MessageBounds + From<Resp>,
Create a new instance from a request and something that can produce a reference to an actor to reply to
This variant is convenient from within a component, as components and their contexts implement ActorRefFactory for their actor message type.
Sourcepub fn from_convert<M>(
content: Req,
sender: &dyn ActorRefFactory<Message = M>,
convert: fn(Resp) -> M,
) -> WithRecipient<Req, Resp>where
M: MessageBounds,
pub fn from_convert<M>(
content: Req,
sender: &dyn ActorRefFactory<Message = M>,
convert: fn(Resp) -> M,
) -> WithRecipient<Req, Resp>where
M: MessageBounds,
Create a new instance from a request and something that can produce a reference to
an actor to reply to, with custom convert function
This variant is convenient from within a component, as components and their contexts implement ActorRefFactory for their actor message type.
Sourcepub fn sender(&self) -> &Recipient<Resp>
pub fn sender(&self) -> &Recipient<Resp>
Returns a strong reference to the response target actor
Sourcepub fn take_content(self) -> Req
pub fn take_content(self) -> Req
Takes only the content
This prevents the request from being completed,
as the sender is dropped!
Use only after replying to the request.
Trait Implementations§
Source§impl<Req, Resp> Debug for WithRecipient<Req, Resp>
impl<Req, Resp> Debug for WithRecipient<Req, Resp>
Source§impl<Req, Resp> Deref for WithRecipient<Req, Resp>where
Req: MessageBounds,
Resp: Debug + 'static,
impl<Req, Resp> Deref for WithRecipient<Req, Resp>where
Req: MessageBounds,
Resp: Debug + 'static,
Source§impl<Req, Resp> Request for WithRecipient<Req, Resp>where
Req: MessageBounds,
Resp: Debug + 'static,
impl<Req, Resp> Request for WithRecipient<Req, Resp>where
Req: MessageBounds,
Resp: Debug + 'static,
Auto Trait Implementations§
impl<Req, Resp> Freeze for WithRecipient<Req, Resp>where
Req: Freeze,
impl<Req, Resp> !RefUnwindSafe for WithRecipient<Req, Resp>
impl<Req, Resp> Send for WithRecipient<Req, Resp>
impl<Req, Resp> Sync for WithRecipient<Req, Resp>where
Req: Sync,
impl<Req, Resp> Unpin for WithRecipient<Req, Resp>where
Req: Unpin,
impl<Req, Resp> UnsafeUnpin for WithRecipient<Req, Resp>where
Req: UnsafeUnpin,
impl<Req, Resp> !UnwindSafe for WithRecipient<Req, Resp>
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> DispatchEvent for T
impl<T> DispatchEvent for T
Source§impl<T, A> DynAccess<T> for A
impl<T, A> DynAccess<T> for A
Source§fn load(&self) -> DynGuard<T>
fn load(&self) -> DynGuard<T>
Access::load.