Caller

Trait Caller 

Source
pub trait Caller:
    Clone
    + Send
    + Sync
    + 'static {
    // Required methods
    fn call_with_metadata<T: Facet<'static> + Send>(
        &self,
        method_id: u64,
        args: &mut T,
        metadata: Metadata,
    ) -> impl Future<Output = Result<ResponseData, TransportError>> + Send;
    fn bind_response_streams<T: Facet<'static>>(
        &self,
        response: &mut T,
        channels: &[u64],
    );

    // Provided method
    fn call<T: Facet<'static> + Send>(
        &self,
        method_id: u64,
        args: &mut T,
    ) -> impl Future<Output = Result<ResponseData, TransportError>> + Send { ... }
}
Expand description

Trait for making RPC calls.

This abstracts over different connection types (e.g., ConnectionHandle, ReconnectingClient) so generated clients can work with any of them.

All callers return TransportError for transport-level failures. Generated clients convert this to CallError<E> which also includes response-level errors like RoamError::User(E).

Required Methods§

Source

fn call_with_metadata<T: Facet<'static> + Send>( &self, method_id: u64, args: &mut T, metadata: Metadata, ) -> impl Future<Output = Result<ResponseData, TransportError>> + Send

Make an RPC call with the given method ID, arguments, and metadata.

The arguments are mutable because stream bindings (Tx/Rx) need to be assigned channel IDs before serialization.

Returns ResponseData containing the payload and any response channel IDs.

Source

fn bind_response_streams<T: Facet<'static>>( &self, response: &mut T, channels: &[u64], )

Bind receivers for Rx<T> streams in the response.

After deserializing a response, any Rx<T> values in it are “hollow” - they have channel IDs but no actual receiver. This method walks the response and binds receivers for each Rx using the channel IDs from the Response message.

Provided Methods§

Source

fn call<T: Facet<'static> + Send>( &self, method_id: u64, args: &mut T, ) -> impl Future<Output = Result<ResponseData, TransportError>> + Send

Make an RPC call with the given method ID and arguments.

The arguments are mutable because stream bindings (Tx/Rx) need to be assigned channel IDs before serialization.

Returns ResponseData containing the payload and any response channel IDs.

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§