Skip to main content

Call

Trait Call 

Source
pub trait Call<'wire, T, E>: MaybeSend
where T: Facet<'wire> + MaybeSend, E: Facet<'wire> + MaybeSend,
{ // Required method fn reply(self, result: Result<T, E>) -> impl Future<Output = ()> + MaybeSend; // Provided methods fn ok(self, value: T) -> impl Future<Output = ()> + MaybeSend where Self: Sized { ... } fn err(self, error: E) -> impl Future<Output = ()> + MaybeSend where Self: Sized { ... } }
Expand description

Represents an in-progress API-level call as seen by a server handler.

A Call is handed to a Handler implementation for one incoming request attempt. It provides the mechanism for sending the terminal response for that attempt back to the caller. The response can be sent via Call::reply, Call::ok, or Call::err.

In the retry model, one logical operation may span multiple request attempts over time, but each Call value corresponds to exactly one request attempt currently being handled.

§Cancellation

If a Call is dropped without a reply being sent, the caller will automatically receive a VoxError::Cancelled error. This guarantees that the caller is always notified, even if the handler panics or otherwise fails to produce a reply.

§Type Parameters

  • T: The success value type of the response.
  • E: The error value type of the response.

Required Methods§

Source

fn reply(self, result: Result<T, E>) -> impl Future<Output = ()> + MaybeSend

Send the terminal response for this request attempt, consuming this Call.

Provided Methods§

Source

fn ok(self, value: T) -> impl Future<Output = ()> + MaybeSend
where Self: Sized,

Send a successful response for this request attempt, consuming this Call.

Equivalent to self.reply(Ok(value)).await.

Source

fn err(self, error: E) -> impl Future<Output = ()> + MaybeSend
where Self: Sized,

Send an error response for this request attempt, consuming this Call.

Equivalent to self.reply(Err(error)).await.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'wire, T, E, R> Call<'wire, T, E> for SinkCall<R>
where T: Facet<'wire> + MaybeSend, E: Facet<'wire> + MaybeSend, R: ReplySink,