pub struct WithSenderStrong<Req, Resp>where
Req: MessageBounds,
Resp: MessageBounds,{ /* private fields */ }Expand description
A generic type for request-response messages with a strong actor reference
This type contains information about the target actor for the response, as well as the actual request itself. It also prevents the response target actor from being deallocated. Since that actor is waiting for a response, this is often a reasonable choice and has performance benefits as well.
Implementations can also be dereferenced to the request message and replied to with a response.
Implementations§
Source§impl<Req, Resp> WithSenderStrong<Req, Resp>where
Req: MessageBounds,
Resp: MessageBounds,
impl<Req, Resp> WithSenderStrong<Req, Resp>where
Req: MessageBounds,
Resp: MessageBounds,
Sourcepub fn new(
content: Req,
sender: ActorRefStrong<Resp>,
) -> WithSenderStrong<Req, Resp>
pub fn new( content: Req, sender: ActorRefStrong<Resp>, ) -> WithSenderStrong<Req, Resp>
Create a new instance from a request and an actor to reply to
Sourcepub fn from(
content: Req,
sender: &dyn ActorRefFactory<Message = Resp>,
) -> WithSenderStrong<Req, Resp>
pub fn from( content: Req, sender: &dyn ActorRefFactory<Message = Resp>, ) -> WithSenderStrong<Req, 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 sender(&self) -> &ActorRefStrong<Resp>
pub fn sender(&self) -> &ActorRefStrong<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 WithSenderStrong<Req, Resp>
impl<Req, Resp> Debug for WithSenderStrong<Req, Resp>
Source§impl<Req, Resp> Deref for WithSenderStrong<Req, Resp>where
Req: MessageBounds,
Resp: MessageBounds,
impl<Req, Resp> Deref for WithSenderStrong<Req, Resp>where
Req: MessageBounds,
Resp: MessageBounds,
Source§impl<Req, Resp> Request for WithSenderStrong<Req, Resp>where
Req: MessageBounds,
Resp: MessageBounds,
impl<Req, Resp> Request for WithSenderStrong<Req, Resp>where
Req: MessageBounds,
Resp: MessageBounds,
Auto Trait Implementations§
impl<Req, Resp> Freeze for WithSenderStrong<Req, Resp>where
Req: Freeze,
impl<Req, Resp> !RefUnwindSafe for WithSenderStrong<Req, Resp>
impl<Req, Resp> Send for WithSenderStrong<Req, Resp>
impl<Req, Resp> Sync for WithSenderStrong<Req, Resp>where
Req: Sync,
impl<Req, Resp> Unpin for WithSenderStrong<Req, Resp>where
Req: Unpin,
impl<Req, Resp> UnsafeUnpin for WithSenderStrong<Req, Resp>where
Req: UnsafeUnpin,
impl<Req, Resp> !UnwindSafe for WithSenderStrong<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.