Skip to main content

RpcSender

Trait RpcSender 

Source
pub trait RpcSender: Send + Sync {
    // Required methods
    fn call_buf(&self) -> CallBuf;
    fn send_call<'life0, 'async_trait>(
        &'life0 self,
        progvers: ProgVers,
        proc: u32,
        call: CallBuf,
    ) -> Pin<Box<dyn Future<Output = Result<RpcResponse, RpcError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn send_fire_and_forget<'life0, 'async_trait>(
        &'life0 self,
        progvers: ProgVers,
        proc: u32,
        call: CallBuf,
    ) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Trait for making outgoing RPC calls.

rpc_driver implements this for real TCP connections (ConnectionHandle, ClientConnection) and for its pooled connections (FixedSerialPool, DynamicPool, CpuSetPool). Inside an RpcHandler dispatch, the per-connection sender is available via rpc_driver::peer().

Generated protocol clients hold an Arc<dyn RpcSender> and are agnostic to which implementation backs it. Implement on a mock struct for unit testing without TCP.

Required Methods§

Source

fn call_buf(&self) -> CallBuf

A buffer to encode the next call into.

Senders that recycle record buffers hand back a spent one, so a steady stream of calls allocates nothing. A sender with nothing to recycle returns CallBuf::new. Encode the arguments into the buffer and pass it to send_call.

Source

fn send_call<'life0, 'async_trait>( &'life0 self, progvers: ProgVers, proc: u32, call: CallBuf, ) -> Pin<Box<dyn Future<Output = Result<RpcResponse, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send an RPC call and return the response.

The call’s arguments arrive encoded in a CallBuf, which the driver frames in place and hands to the socket without copying. The returned RpcResponse derefs to &[u8] for zero-copy deserialization, or can be copied to an owned Vec<u8> via .to_vec().

Provided Methods§

Source

fn send_fire_and_forget<'life0, 'async_trait>( &'life0 self, progvers: ProgVers, proc: u32, call: CallBuf, ) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send an RPC call without waiting for the response.

Default implementation calls send_call and discards the response. Implementations may override this to return after queueing the request, in which case success does not confirm socket delivery or peer-side dispatch.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§