Client

Trait Client 

Source
pub trait Client: MaybeSend + MaybeSync {
    type Error: Error + MaybeSend + MaybeSync + 'static;
    type Stream: Stream<Item = Result<Bytes, Self::Error>> + MaybeSend;

    // Required methods
    fn request<'life0, 'async_trait>(
        &'life0 self,
        request: Builder,
        path: PathAndQuery,
        body: Bytes,
    ) -> Pin<Box<dyn Future<Output = Result<Response<Bytes>, ApiClientError<Self::Error>>> + 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<Self::Stream>, ApiClientError<Self::Error>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn fake_stream(&self) -> Response<Self::Stream>;
}
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 Associated Types§

Source

type Error: Error + MaybeSend + MaybeSync + 'static

Source

type Stream: Stream<Item = Result<Bytes, Self::Error>> + MaybeSend

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<Self::Error>>> + 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<Self::Stream>, ApiClientError<Self::Error>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn fake_stream(&self) -> Response<Self::Stream>

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§

type Error = <T as Client>::Error

Source§

type Stream = <T as Client>::Stream

Source§

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

Source§

fn fake_stream(&self) -> Response<Self::Stream>

Source§

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

Source§

type Error = <T as Client>::Error

Source§

type Stream = <T as Client>::Stream

Source§

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

Source§

fn fake_stream(&self) -> Response<Self::Stream>

Source§

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

Source§

fn fake_stream(&self) -> Response<Self::Stream>

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

Source§

type Error = <T as Client>::Error

Source§

type Stream = <T as Client>::Stream

Source§

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

Implementors§