[][src]Struct surf::Client

pub struct Client<C: HttpClient> { /* fields omitted */ }

An HTTP client, capable of creating new Requests.

Examples

let client = surf::Client::new();
let req1 = client.get("https://httpbin.org/get").recv_string();
let req2 = client.get("https://httpbin.org/get").recv_string();
let (str1, str2) = futures::future::try_join(req1, req2).await?;

Methods

impl Client<NativeClient>[src]

pub fn new() -> Self[src]

Create a new instance.

Examples

let client = surf::Client::new();

impl<C: HttpClient> Client<C>[src]

Important traits for Request<C>
pub fn get(&self, uri: impl AsRef<str>) -> Request<C>[src]

Perform an HTTP GET request using the Client connection.

Panics

This will panic if a malformed URL is passed.

Errors

Returns errors from the middleware, http backend, and network sockets.

Examples

let client = surf::Client::new();
let string = client.get("https://httpbin.org/get").recv_string().await?;

Important traits for Request<C>
pub fn head(&self, uri: impl AsRef<str>) -> Request<C>[src]

Perform an HTTP HEAD request using the Client connection.

Panics

This will panic if a malformed URL is passed.

Errors

Returns errors from the middleware, http backend, and network sockets.

Examples

let client = surf::Client::new();
let string = client.head("https://httpbin.org/head").recv_string().await?;

Important traits for Request<C>
pub fn post(&self, uri: impl AsRef<str>) -> Request<C>[src]

Perform an HTTP POST request using the Client connection.

Panics

This will panic if a malformed URL is passed.

Errors

Returns errors from the middleware, http backend, and network sockets.

Examples

let client = surf::Client::new();
let string = client.post("https://httpbin.org/post").recv_string().await?;

Important traits for Request<C>
pub fn put(&self, uri: impl AsRef<str>) -> Request<C>[src]

Perform an HTTP PUT request using the Client connection.

Panics

This will panic if a malformed URL is passed.

Errors

Returns errors from the middleware, http backend, and network sockets.

Examples

let client = surf::Client::new();
let string = client.put("https://httpbin.org/put").recv_string().await?;

Important traits for Request<C>
pub fn delete(&self, uri: impl AsRef<str>) -> Request<C>[src]

Perform an HTTP DELETE request using the Client connection.

Panics

This will panic if a malformed URL is passed.

Errors

Returns errors from the middleware, http backend, and network sockets.

Examples

let client = surf::Client::new();
let string = client.delete("https://httpbin.org/delete").recv_string().await?;

Important traits for Request<C>
pub fn connect(&self, uri: impl AsRef<str>) -> Request<C>[src]

Perform an HTTP CONNECT request using the Client connection.

Panics

This will panic if a malformed URL is passed.

Errors

Returns errors from the middleware, http backend, and network sockets.

Examples

let client = surf::Client::new();
let string = client.connect("https://httpbin.org/connect").recv_string().await?;

Important traits for Request<C>
pub fn options(&self, uri: impl AsRef<str>) -> Request<C>[src]

Perform an HTTP OPTIONS request using the Client connection.

Panics

This will panic if a malformed URL is passed.

Errors

Returns errors from the middleware, http backend, and network sockets.

Examples

let client = surf::Client::new();
let string = client.options("https://httpbin.org/options").recv_string().await?;

Important traits for Request<C>
pub fn trace(&self, uri: impl AsRef<str>) -> Request<C>[src]

Perform an HTTP TRACE request using the Client connection.

Panics

This will panic if a malformed URL is passed.

Errors

Returns errors from the middleware, http backend, and network sockets.

Examples

let client = surf::Client::new();
let string = client.trace("https://httpbin.org/trace").recv_string().await?;

Important traits for Request<C>
pub fn patch(&self, uri: impl AsRef<str>) -> Request<C>[src]

Perform an HTTP PATCH request using the Client connection.

Panics

This will panic if a malformed URL is passed.

Errors

Returns errors from the middleware, http backend, and network sockets.

Examples

let client = surf::Client::new();
let string = client.patch("https://httpbin.org/patch").recv_string().await?;

Trait Implementations

impl<C: Default + HttpClient> Default for Client<C>[src]

impl<C: Debug + HttpClient> Debug for Client<C>[src]

Auto Trait Implementations

impl<C> Send for Client<C>

impl<C> Sync for Client<C>

impl<C> Unpin for Client<C>

impl<C> UnwindSafe for Client<C> where
    C: UnwindSafe

impl<C> RefUnwindSafe for Client<C> where
    C: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]