pub struct Response<T> { /* private fields */ }Expand description
Response.
§Notes
- When the response is dropped inside the actor and has not been used we receive a canceled on the caller side.
Implementations§
Source§impl<T> Response<T>
impl<T> Response<T>
Sourcepub fn respond(self, value: T)
pub fn respond(self, value: T)
Send Response to caller.
§Notes
- Ignores when the caller is not waiting for the response. When you want to handle this use
Response::send.
Sourcepub async fn respond_execute<Fut, F>(self, value: F)
pub async fn respond_execute<Fut, F>(self, value: F)
Executes closure and respond with the result
Sourcepub fn send(self, value: T) -> Result<(), ActorError>
pub fn send(self, value: T) -> Result<(), ActorError>
Try to send response to caller.
§Errors
- Fails with
ActorError::Canceledwhen the caller is not waiting for the result.
Sourcepub async fn execute<Fut, F>(self, value: F) -> Result<(), ActorError>
pub async fn execute<Fut, F>(self, value: F) -> Result<(), ActorError>
Executes closure and respond with the result
Sourcepub fn spawn_with<Fut, F>(self, spawner: impl Borrow<TaskSpawner>, value: F)
pub fn spawn_with<Fut, F>(self, spawner: impl Borrow<TaskSpawner>, value: F)
Spawns a new task using the given spawner and executes given closure in it
Sourcepub fn spawn_local<Fut, F>(self, spawner: impl LocalTaskSpawner, value: F)
pub fn spawn_local<Fut, F>(self, spawner: impl LocalTaskSpawner, value: F)
Spawns a new task using the given spawner and executes given closure in it
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Response<T>
impl<T> !RefUnwindSafe for Response<T>
impl<T> Send for Response<T>where
T: Send,
impl<T> Sync for Response<T>where
T: Send,
impl<T> Unpin for Response<T>
impl<T> UnsafeUnpin for Response<T>
impl<T> !UnwindSafe for Response<T>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more