ClientEncoding

Trait ClientEncoding 

Source
pub trait ClientEncoding<Service: ?Sized + 'static>: Sized {
    // Required method
    fn invoke<R: Serialize + Sync>(
        client: &Client<Service>,
        method_id: u16,
        request: &R,
    ) -> impl Future<Output = Self> + Send;
}
Expand description

Trait for making client calls with automatic encoding/decoding.

This trait is automatically implemented for:

  • Result<T, anyhow::Error> where T: DeserializeOwned - unary calls
  • Result<RpcStream<T>, anyhow::Error> - streaming calls

Required Methods§

Source

fn invoke<R: Serialize + Sync>( client: &Client<Service>, method_id: u16, request: &R, ) -> impl Future<Output = Self> + Send

Invoke a remote method and decode the response.

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.

Implementations on Foreign Types§

Source§

impl<S: ?Sized + Sync + 'static, T: DeserializeOwned + Send + 'static> ClientEncoding<S> for Result<RpcStream<T>, Error>

Streaming call encoding for RpcStream results. This impl doesn’t conflict with the above because RpcStream doesn’t impl DeserializeOwned.

Source§

async fn invoke<R: Serialize + Sync>( client: &Client<S>, method_id: u16, request: &R, ) -> Self

Source§

impl<S: ?Sized + Sync + 'static, T: DeserializeOwned + Send> ClientEncoding<S> for Result<T, Error>

Unary call encoding for any deserializable Result type.

Source§

async fn invoke<R: Serialize + Sync>( client: &Client<S>, method_id: u16, request: &R, ) -> Self

Implementors§