Skip to main content

ReplySink

Trait ReplySink 

Source
pub trait ReplySink:
    MaybeSend
    + MaybeSync
    + 'static {
    // Required method
    fn send_reply(
        self,
        response: RequestResponse<'_>,
    ) -> impl Future<Output = ()> + MaybeSend;

    // Provided methods
    fn send_error<E: for<'a> Facet<'a> + MaybeSend>(
        self,
        error: VoxError<E>,
    ) -> impl Future<Output = ()> + MaybeSend
       where Self: Sized { ... }
    fn send_typed_error<'wire, T, E>(
        self,
        error: VoxError<E>,
    ) -> impl Future<Output = ()> + MaybeSend
       where Self: Sized,
             T: Facet<'wire> + MaybeSend,
             E: Facet<'wire> + MaybeSend { ... }
    fn channel_binder(&self) -> Option<&dyn ChannelBinder> { ... }
    fn request_id(&self) -> Option<RequestId> { ... }
    fn connection_id(&self) -> Option<ConnectionId> { ... }
}
Expand description

Sink for sending the terminal response for one request attempt.

Implemented by the session driver. Provides backpressure: send_reply awaits until the transport can accept the response before serializing it.

§Cancellation

If the ReplySink is dropped without send_reply being called, the caller will automatically receive a crate::VoxError::Cancelled error.

Required Methods§

Source

fn send_reply( self, response: RequestResponse<'_>, ) -> impl Future<Output = ()> + MaybeSend

Send the terminal response for this request attempt, consuming the sink. Any error that happens during send_reply must set a flag in the driver for it to resolve the attempt as failed.

This cannot return a Result because we cannot trust callers to deal with it, and they cannot try sending a second response anyway.

Do not spawn a task to send the error because it too, might fail.

Provided Methods§

Source

fn send_error<E: for<'a> Facet<'a> + MaybeSend>( self, error: VoxError<E>, ) -> impl Future<Output = ()> + MaybeSend
where Self: Sized,

Send an error response for this request attempt, consuming the sink.

This is a convenience method used by generated dispatchers when deserialization fails or the method ID is unknown.

Source

fn send_typed_error<'wire, T, E>( self, error: VoxError<E>, ) -> impl Future<Output = ()> + MaybeSend
where Self: Sized, T: Facet<'wire> + MaybeSend, E: Facet<'wire> + MaybeSend,

Send an error response using the full wire shape Result<T, VoxError<E>>.

This preserves the method’s real Ok type for schema extraction.

Source

fn channel_binder(&self) -> Option<&dyn ChannelBinder>

Return a channel binder for binding Tx/Rx handles in deserialized args.

Returns None by default. The driver’s ReplySink implementation overrides this to provide actual channel binding.

Source

fn request_id(&self) -> Option<RequestId>

Return the wire-level request identifier for this reply sink when available.

Source

fn connection_id(&self) -> Option<ConnectionId>

Return the virtual connection identifier for this reply sink when available.

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§