[][src]Trait syncthing::HttpClient

pub trait HttpClient: 'static + Clone + Send + Sync + Unpin + Debug {
    type Error: Error + Send + Sync;
    fn send(
        &self,
        req: Request<Body>
    ) -> Pin<Box<dyn Future<Output = Result<Response<Body>, Self::Error>> + 'static + Send>>; }

[unstable] An abstract HTTP client.

note that this is only exposed for use in middleware. Building new backing clients is not recommended yet. Once it is we'll likely publish a new http-client crate, and re-export this trait from there together with all existing HTTP client implementations.

Spawning new request from middleware

When threading the trait through a layer of middleware, the middleware must be able to perform new requests. In order to enable this we pass an HttpClient instance through the middleware, with a Clone implementation. In order to spawn a new request, clone is called, and a new request is enabled.

How Clone is implemented is up to the implementors, but in an ideal scenario combining this with the Client builder will allow for high connection reuse, improving latency.

Associated Types

type Error: Error + Send + Sync

The associated error type.

Loading content...

Required methods

fn send(
    &self,
    req: Request<Body>
) -> Pin<Box<dyn Future<Output = Result<Response<Body>, Self::Error>> + 'static + Send>>

Perform a request.

Loading content...

Implementors

Loading content...