pub trait Client: MaybeSend + MaybeSync {
// Required methods
fn host(&self) -> &str;
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 has_credential_source(&self) -> bool { ... }
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§
Sourcefn host(&self) -> &str
fn host(&self) -> &str
The URL this transport dials — its connection identity. Two clients share process-level connection state (the XIP-83 shared bidi wire) exactly when their hosts match, so this must name where the bytes actually go: a client behind a proxy reports the proxy’s URL, keeping it a separate failure domain from a direct client to the same backend.
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§
Sourcefn has_credential_source(&self) -> bool
fn has_credential_source(&self) -> bool
Whether this transport stack was given a way to obtain a credential —
an auth callback or an auth handle (CFG-062). A stack with no auth
middleware in it reports false, and build refuses a deployment that
requires authentication.
Sourcefn 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 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.
Sourcefn fake_stream(&self) -> Response<BytesStream>
fn fake_stream(&self) -> Response<BytesStream>
start a “fake” stream that does not create a TCP connection and will always be pending