pub struct Rpc<I, R>(/* private fields */);
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>
.
Implementations§
Source§impl<I, R: 'static + Send> Rpc<I, R>
impl<I, R: 'static + Send> Rpc<I, R>
Sourcepub fn detached(input: I) -> Self
pub fn detached(input: I) -> Self
Returns a new RPC message with input
and no one listening for the
result.
Sourcepub fn split(self) -> (I, Rpc<(), R>)
pub fn split(self) -> (I, Rpc<(), R>)
Splits the RPC into its input and an input-less RPC. This is useful when the input is needed in one place but the RPC will be completed in another.
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] = _
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>
impl<I, R> Sync for Rpc<I, R>
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: 'static + MeshPayload + Send,
impl<T> SerializeMessage for Twhere
T: 'static + MeshPayload + Send,
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
.