Skip to main content

WithSender

Struct WithSender 

Source
pub struct WithSender<Req, Resp>
where Req: MessageBounds, Resp: MessageBounds,
{ /* private fields */ }
Expand description

A generic type for request-response messages

This type contains 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> WithSender<Req, Resp>
where Req: MessageBounds, Resp: MessageBounds,

Source

pub fn new(content: Req, sender: ActorRef<Resp>) -> WithSender<Req, Resp>

Create a new instance from a request and an actor to reply to

Source

pub fn from( content: Req, sender: &dyn ActorRefFactory<Message = Resp>, ) -> WithSender<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.

Source

pub fn sender(&self) -> &ActorRef<Resp>

Returns a reference to the response target actor

Source

pub fn content(&self) -> &Req

Returns a reference to the content

Source

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 WithSender<Req, Resp>
where Req: Debug + MessageBounds, Resp: Debug + MessageBounds,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<Req, Resp> Deref for WithSender<Req, Resp>
where Req: MessageBounds, Resp: MessageBounds,

Source§

type Target = Req

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<WithSender<Req, Resp> as Deref>::Target

Dereferences the value.
Source§

impl<Req, Resp> Request for WithSender<Req, Resp>
where Req: MessageBounds, Resp: MessageBounds,

Source§

type Response = Resp

The type of the response that is expected
Source§

fn reply(&self, resp: <WithSender<Req, Resp> as Request>::Response)

Fulfill this request by supplying a response of the appropriate type

Auto Trait Implementations§

§

impl<Req, Resp> Freeze for WithSender<Req, Resp>
where Req: Freeze,

§

impl<Req, Resp> !RefUnwindSafe for WithSender<Req, Resp>

§

impl<Req, Resp> Send for WithSender<Req, Resp>

§

impl<Req, Resp> Sync for WithSender<Req, Resp>
where Req: Sync,

§

impl<Req, Resp> Unpin for WithSender<Req, Resp>
where Req: Unpin,

§

impl<Req, Resp> UnsafeUnpin for WithSender<Req, Resp>
where Req: UnsafeUnpin,

§

impl<Req, Resp> !UnwindSafe for WithSender<Req, Resp>

Blanket Implementations§

Source§

impl<T, A, P> Access<T> for P
where A: Access<T> + ?Sized, P: Deref<Target = A>,

Source§

type Guard = <A as Access<T>>::Guard

A guard object containing the value and keeping it alive. Read more
Source§

fn load(&self) -> <P as Access<T>>::Guard

The loading method. Read more
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> DispatchEvent for T
where T: Any + Send + Debug,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any + Send>

Convert this event into an erased Any payload for downcasting.
Source§

impl<T, A> DynAccess<T> for A
where A: Access<T>, <A as Access<T>>::Guard: 'static,

Source§

fn load(&self) -> DynGuard<T>

The equivalent of Access::load.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> Erased for T

Source§

impl<T> Formattable for T
where T: Deref, <T as Deref>::Target: Formattable,

Source§

impl<M> MessageBounds for M
where M: Debug + Send + 'static,