Struct jupiter::commands::Call

source ·
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

source

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.

source

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.

source

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> 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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more