pub trait Client<Error, InputStreamError = Error, OutputStreamError = Error> {
type Request: ClientReq<Error> + Send + 'static;
type Response: ClientRes<Error> + Send + 'static;
// Required methods
fn send(
req: Self::Request,
) -> impl Future<Output = Result<Self::Response, Error>> + Send;
fn open_websocket(
path: &str,
) -> impl Future<Output = Result<(impl Stream<Item = Result<Bytes, Bytes>> + Send + 'static, impl Sink<Bytes> + Send + 'static), Error>> + Send;
fn spawn(future: impl Future<Output = ()> + Send + 'static);
}
Expand description
A client defines a pair of request/response types and the logic to send and receive them.
This trait is implemented for things like a browser fetch
request or for
the reqwest
trait. It should almost never be necessary to implement it
yourself, unless you’re trying to use an alternative HTTP crate on the client side.
Required Associated Types§
Required Methods§
Sourcefn send(
req: Self::Request,
) -> impl Future<Output = Result<Self::Response, Error>> + Send
fn send( req: Self::Request, ) -> impl Future<Output = Result<Self::Response, Error>> + Send
Sends the request and receives a 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.