Skip to main content

Client

Trait Client 

Source
pub trait Client: MaybeSend + MaybeSync {
    // Required methods
    fn request<'life0, 'async_trait>(
        &'life0 self,
        request: Builder,
        path: PathAndQuery,
        body: Bytes,
    ) -> Pin<Box<dyn Future<Output = Result<Response<Bytes>, ApiClientError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn stream<'life0, 'async_trait>(
        &'life0 self,
        request: Builder,
        path: PathAndQuery,
        body: Bytes,
    ) -> Pin<Box<dyn Future<Output = Result<Response<BytesStream>, ApiClientError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn bidi_stream<'life0, 'async_trait>(
        &'life0 self,
        request: Builder,
        path: PathAndQuery,
        body: BoxDynStream<'static, Bytes>,
    ) -> Pin<Box<dyn Future<Output = Result<Response<BytesStream>, ApiClientError>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait { ... }
    fn fake_stream(&self) -> Response<BytesStream> { ... }
}
Expand description

A client represents how a request body is formed and sent into a backend. The client is protocol agnostic, a Client may communicate with a backend over gRPC, JSON-RPC, HTTP-REST, etc. http::Response’s are used in order to maintain a common data format compatible with a wide variety of backends. an http response is easily derived from a grpc, jsonrpc or rest api.

Required Methods§

Source

fn request<'life0, 'async_trait>( &'life0 self, request: Builder, path: PathAndQuery, body: Bytes, ) -> Pin<Box<dyn Future<Output = Result<Response<Bytes>, ApiClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn stream<'life0, 'async_trait>( &'life0 self, request: Builder, path: PathAndQuery, body: Bytes, ) -> Pin<Box<dyn Future<Output = Result<Response<BytesStream>, ApiClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Provided Methods§

Source

fn bidi_stream<'life0, 'async_trait>( &'life0 self, request: Builder, path: PathAndQuery, body: BoxDynStream<'static, Bytes>, ) -> Pin<Box<dyn Future<Output = Result<Response<BytesStream>, ApiClientError>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

Open a bidirectional stream (XIP-83). body is the outbound stream of encoded protobuf messages (one Bytes item per message); the response carries the inbound message stream. Transports without full-duplex support (e.g. gRPC-Web in the browser) keep this default and error.

Source

fn fake_stream(&self) -> Response<BytesStream>

start a “fake” stream that does not create a TCP connection and will always be pending

Implementations on Foreign Types§

Source§

impl<T> Client for &T
where T: Client + MaybeSend + MaybeSync + ?Sized,

Source§

fn request<'life0, 'async_trait>( &'life0 self, request: Builder, path: PathAndQuery, body: Bytes, ) -> Pin<Box<dyn Future<Output = Result<Response<Bytes>, ApiClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn stream<'life0, 'async_trait>( &'life0 self, request: Builder, path: PathAndQuery, body: Bytes, ) -> Pin<Box<dyn Future<Output = Result<Response<BytesStream>, ApiClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn bidi_stream<'life0, 'async_trait>( &'life0 self, request: Builder, path: PathAndQuery, body: BoxDynStream<'static, Bytes>, ) -> Pin<Box<dyn Future<Output = Result<Response<BytesStream>, ApiClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

impl<T> Client for Box<T>
where T: Client + MaybeSend + MaybeSync + ?Sized,

Source§

fn request<'life0, 'async_trait>( &'life0 self, request: Builder, path: PathAndQuery, body: Bytes, ) -> Pin<Box<dyn Future<Output = Result<Response<Bytes>, ApiClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn stream<'life0, 'async_trait>( &'life0 self, request: Builder, path: PathAndQuery, body: Bytes, ) -> Pin<Box<dyn Future<Output = Result<Response<BytesStream>, ApiClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn bidi_stream<'life0, 'async_trait>( &'life0 self, request: Builder, path: PathAndQuery, body: BoxDynStream<'static, Bytes>, ) -> Pin<Box<dyn Future<Output = Result<Response<BytesStream>, ApiClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

impl<T> Client for Arc<T>
where T: Client + MaybeSend + MaybeSync + ?Sized,

Source§

fn request<'life0, 'async_trait>( &'life0 self, request: Builder, path: PathAndQuery, body: Bytes, ) -> Pin<Box<dyn Future<Output = Result<Response<Bytes>, ApiClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn stream<'life0, 'async_trait>( &'life0 self, request: Builder, path: PathAndQuery, body: Bytes, ) -> Pin<Box<dyn Future<Output = Result<Response<BytesStream>, ApiClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn bidi_stream<'life0, 'async_trait>( &'life0 self, request: Builder, path: PathAndQuery, body: BoxDynStream<'static, Bytes>, ) -> Pin<Box<dyn Future<Output = Result<Response<BytesStream>, ApiClientError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Implementors§