pub struct Call {
pub request: Request,
pub response: Response,
pub token: usize,
/* private fields */
}
Expand description
Represents the invocation of a command.
This wraps the request, a pre-initialized result and the command index (token) in a single struct which is then sent to the actor executing the command using a queue. It also contains the callback which is another (oneshot) queue to send back the result - however this is completely handled internally, therefore only complete has to be called for this call to finish processing a command.
Fields§
§request: Request
Contains the request as sent by the client.
response: Response
Contains the response to be filled with the response data
token: usize
Contains the index of the commend being called.
This is required as commonly a bunch of commands share a single queue, so that the invocation of these commands is “single threaded” from the view of the actor.
Implementations§
source§impl Call
impl Call
sourcepub fn complete(self, result: CommandResult)
pub fn complete(self, result: CommandResult)
Marks the command represented by this call as handled.
In case of a successful completion, this simply closes the response and sends the serialized data back to the caller. In case of an error, an appropriate representation is generated and sent back as alternative response. However, in case of an OutputError, we directly send error back to the caller, as the connection might be in an inconsistent state. The caller then will most probably try to write an error and then close the connection to prevent any further inconsistencies.
sourcepub fn complete_output(self, result: Result<(), OutputError>)
pub fn complete_output(self, result: Result<(), OutputError>)
Manually completes a call by directly accepting an output result.
Commonly, the complete method is used to complete a call, must probably via (ResultExt)ResultExt. However, some handlers, directly complete a call manually by invoking a method on response, which result can be handled here.
sourcepub fn handle_unknown_token(self)
pub fn handle_unknown_token(self)
Handles an unknown token by completing with an appropriate error.
Auto Trait Implementations§
impl !Freeze for Call
impl !RefUnwindSafe for Call
impl Send for Call
impl Sync for Call
impl Unpin for Call
impl !UnwindSafe for Call
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> 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>
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>
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