Struct mesh_channel::rpc::Rpc
source · pub struct Rpc<I, R>(pub I, pub OneshotSender<R>);
Expand description
An RPC message for a request with input of type I
and output of type R
.
The receiver of the message should process the request and return results
via the Sender<R>
.
Tuple Fields§
§0: I
§1: OneshotSender<R>
Implementations§
source§impl<I, R: 'static + Send> Rpc<I, R>
impl<I, R: 'static + Send> Rpc<I, R>
sourcepub fn handle_sync<F>(self, f: F)where
F: FnOnce(I) -> R,
pub fn handle_sync<F>(self, f: F)where
F: FnOnce(I) -> R,
Handles an RPC request by calling f
and sending the result to the
initiator.
sourcepub async fn handle<F, Fut>(self, f: F)
pub async fn handle<F, Fut>(self, f: F)
Handles an RPC request by calling f
, awaiting its result, and sending
the result to the initiator.
sourcepub async fn handle_must_succeed<F, Fut, E>(self, f: F) -> Result<(), E>
pub async fn handle_must_succeed<F, Fut, E>(self, f: F) -> Result<(), E>
Handles an RPC request by calling f
, awaiting its result, and sending
Ok results back to the initiator.
If f
fails, the error is propagated back to the caller, and the RPC
channel is dropped (resulting in a RecvError::Closed
on the
initiator).
source§impl<I, R: 'static + Send> Rpc<I, Result<R, RemoteError>>
impl<I, R: 'static + Send> Rpc<I, Result<R, RemoteError>>
sourcepub fn handle_failable_sync<F, E>(self, f: F)
pub fn handle_failable_sync<F, E>(self, f: F)
Handles an RPC request by calling f
and sending the result to the
initiator, after converting any error to a RemoteError
.
sourcepub async fn handle_failable<F, Fut, E>(self, f: F)
pub async fn handle_failable<F, Fut, E>(self, f: F)
Handles an RPC request by calling f
, awaiting its result, and sending
the result to the initiator, after converting any error to a
RemoteError
.
Trait Implementations§
source§impl<I, R> DefaultEncoding for Rpc<I, R>
impl<I, R> DefaultEncoding for Rpc<I, R>
source§type Encoding = TableEncoder
type Encoding = TableEncoder
source§impl<'encoding, I, R> StructDecodeMetadata<'encoding, Resource> for Rpc<I, R>
impl<'encoding, I, R> StructDecodeMetadata<'encoding, Resource> for Rpc<I, R>
source§const DECODERS: &'static [ErasedDecoderEntry] = _
const DECODERS: &'static [ErasedDecoderEntry] = _
source§impl<I, R> StructEncodeMetadata<Resource> for Rpc<I, R>
impl<I, R> StructEncodeMetadata<Resource> for Rpc<I, R>
source§const ENCODERS: &'static [ErasedEncoderEntry] = _
const ENCODERS: &'static [ErasedEncoderEntry] = _
source§impl<I, R> StructMetadata for Rpc<I, R>
impl<I, R> StructMetadata for Rpc<I, R>
impl<I, R, I_mapped, R_mapped> Downcast<Rpc<I_mapped, R_mapped>> for Rpc<I, R>where
I: MeshField + Downcast<I_mapped>,
R: MeshField,
OneshotSender<R>: Downcast<OneshotSender<R_mapped>>,
Auto Trait Implementations§
impl<I, R> Freeze for Rpc<I, R>where
I: Freeze,
impl<I, R> !RefUnwindSafe for Rpc<I, R>
impl<I, R> Send for Rpc<I, R>where
I: Send,
impl<I, R> Sync for Rpc<I, R>where
I: Sync,
impl<I, R> Unpin for Rpc<I, R>where
I: Unpin,
impl<I, R> !UnwindSafe for Rpc<I, R>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> SerializeMessage for Twhere
T: MeshPayload,
impl<T> SerializeMessage for Twhere
T: MeshPayload,
source§fn compute_message_size(&mut self, sizer: MessageSizer<'_>)
fn compute_message_size(&mut self, sizer: MessageSizer<'_>)
MessageEncode::compute_message_size
.source§fn write_message(self, writer: MessageWriter<'_, '_, Resource>)
fn write_message(self, writer: MessageWriter<'_, '_, Resource>)
MessageEncode::write_message
.