Client

Trait Client 

Source
pub trait Client:
    Send
    + Sync
    + Unpin
    + 'static {
    type Url: Display + Send + Sync + Unpin;
    type Headers: ResponseHeaders;
    type Response: ClientResponse<Headers = Self::Headers>;
    type Error: Error + Send + Sync;

    // Required methods
    fn create() -> Self;
    fn get(
        &self,
        url: &Self::Url,
    ) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send;
    fn get_range(
        &self,
        url: &Self::Url,
        start: u64,
        end: Option<u64>,
    ) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send;
}
Available on crate feature http only.
Expand description

Wrapper trait for an HTTP client that exposes only functionality necessary for retrieving the stream content. If the reqwest feature is enabled, this trait is implemented for reqwest::Client. This can be implemented for a custom HTTP client if desired.

Required Associated Types§

Source

type Url: Display + Send + Sync + Unpin

The HTTP URL of the remote resource.

Source

type Headers: ResponseHeaders

The type that contains the HTTP response headers.

Source

type Response: ClientResponse<Headers = Self::Headers>

The HTTP response object.

Source

type Error: Error + Send + Sync

The error type returned by HTTP requests.

Required Methods§

Source

fn create() -> Self

Creates a new instance of the client.

Source

fn get( &self, url: &Self::Url, ) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send

Sends an HTTP GET request to the URL.

Source

fn get_range( &self, url: &Self::Url, start: u64, end: Option<u64>, ) -> impl Future<Output = Result<Self::Response, Self::Error>> + Send

Sends an HTTP GET request to the URL utilizing the Range header to request a specific part of the stream.

The end value should be inclusive, per the HTTP spec.

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.

Implementations on Foreign Types§

Source§

impl Client for ClientWithMiddleware

Available on crate feature reqwest-middleware only.
Source§

type Url = Url

Source§

type Response = Response

Source§

type Error = Error

Source§

type Headers = HeaderMap

Source§

fn create() -> Self

Source§

async fn get(&self, url: &Self::Url) -> Result<Self::Response, Self::Error>

Source§

async fn get_range( &self, url: &Self::Url, start: u64, end: Option<u64>, ) -> Result<Self::Response, Self::Error>

Source§

impl Client for Client

Available on crate feature reqwest only.
Source§

type Url = Url

Source§

type Response = Response

Source§

type Error = Error

Source§

type Headers = HeaderMap

Source§

fn create() -> Self

Source§

async fn get(&self, url: &Self::Url) -> Result<Self::Response, Self::Error>

Source§

async fn get_range( &self, url: &Self::Url, start: u64, end: Option<u64>, ) -> Result<Self::Response, Self::Error>

Implementors§