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: RoamError<E>,
) -> impl Future<Output = ()> + MaybeSend
where Self: Sized { ... }
fn channel_binder(&self) -> Option<&dyn ChannelBinder> { ... }
}Expand description
Sink for sending a reply back to the caller.
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::RoamError::Cancelled error.
Required Methods§
Sourcefn send_reply(
self,
response: RequestResponse<'_>,
) -> impl Future<Output = ()> + MaybeSend
fn send_reply( self, response: RequestResponse<'_>, ) -> impl Future<Output = ()> + MaybeSend
Send the response, consuming the sink. Any error that happens during send_reply must set a flag in the driver for it to reply with an error.
This cannot return a Result because we cannot trust callers to deal with it, and it’s not like they can try sending a second reply anyway.
Do not spawn a task to send the error because it too, might fail.
Provided Methods§
Sourcefn send_error<E: for<'a> Facet<'a> + MaybeSend>(
self,
error: RoamError<E>,
) -> impl Future<Output = ()> + MaybeSendwhere
Self: Sized,
fn send_error<E: for<'a> Facet<'a> + MaybeSend>(
self,
error: RoamError<E>,
) -> impl Future<Output = ()> + MaybeSendwhere
Self: Sized,
Send an error response back to the caller, consuming the sink.
This is a convenience method used by generated dispatchers when deserialization fails or the method ID is unknown.
Sourcefn channel_binder(&self) -> Option<&dyn ChannelBinder>
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.
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.