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§
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,
Sourcefn fake_stream(&self) -> Response<Self::Stream>
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
impl<T> Client for &T
type Error = <T as Client>::Error
type Stream = <T as Client>::Stream
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>
Source§impl<T> Client for Box<T>
impl<T> Client for Box<T>
type Error = <T as Client>::Error
type Stream = <T as Client>::Stream
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>
Source§impl<T> Client for Arc<T>
impl<T> Client for Arc<T>
Source§fn fake_stream(&self) -> Response<Self::Stream>
fn fake_stream(&self) -> Response<Self::Stream>
start a “fake” stream that does not create a TCP connection and will always be pending