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 call from a client that must be replied to.

A Call is handed to a Handler implementation and provides the mechanism for sending a response back to the caller. The response can be sent via Call::reply, Call::ok, or Call::err.

§Cancellation

If a Call is dropped without a reply being sent, the caller will automatically receive a RoamError::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 a Result back to the caller, consuming this Call.

Provided Methods§

Source

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

Send a successful response back to the caller, 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 back to the caller, 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,