[][src]Struct restson::RestClient

pub struct RestClient { /* fields omitted */ }

REST client to make HTTP GET and POST requests.

Implementations

impl RestClient[src]

pub fn new(url: &str) -> Result<RestClient, Error>[src]

Construct new client with default configuration to make HTTP requests.

Use Builder to configure the client.

pub fn builder() -> Builder[src]

Configure a client

pub fn set_send_null_body(&mut self, send_null: bool)[src]

Set whether a message body consisting only 'null' (from serde serialization) is sent in POST/PUT

pub fn set_auth(&mut self, user: &str, pass: &str)[src]

Set credentials for HTTP Basic authentication.

pub fn set_body_wash_fn(&mut self, func: fn(_: String) -> String)[src]

Set a function that cleans the response body up before deserializing it.

pub fn set_timeout(&mut self, timeout: Duration)[src]

Set request timeout

pub fn set_header(
    &mut self,
    name: &'static str,
    value: &str
) -> Result<(), Error>
[src]

Set HTTP header from string name and value.

The header is added to all subsequent GET and POST requests unless the headers are cleared with clear_headers() call.

pub fn clear_headers(&mut self)[src]

Clear all previously set headers

pub fn response_headers(&mut self) -> &HeaderMap[src]

Response headers captured from previous request

pub fn get<U, T>(&mut self, params: U) -> Result<T, Error> where
    T: DeserializeOwned + RestPath<U>, 
[src]

Make a GET request.

pub fn get_with<U, T>(
    &mut self,
    params: U,
    query: &Query<'_>
) -> Result<T, Error> where
    T: DeserializeOwned + RestPath<U>, 
[src]

Make a GET request with query parameters.

pub fn post<U, T>(&mut self, params: U, data: &T) -> Result<(), Error> where
    T: Serialize + RestPath<U>, 
[src]

Make a POST request.

pub fn put<U, T>(&mut self, params: U, data: &T) -> Result<(), Error> where
    T: Serialize + RestPath<U>, 
[src]

Make a PUT request.

pub fn patch<U, T>(&mut self, params: U, data: &T) -> Result<(), Error> where
    T: Serialize + RestPath<U>, 
[src]

Make a PATCH request.

pub fn post_with<U, T>(
    &mut self,
    params: U,
    data: &T,
    query: &Query<'_>
) -> Result<(), Error> where
    T: Serialize + RestPath<U>, 
[src]

Make POST request with query parameters.

pub fn put_with<U, T>(
    &mut self,
    params: U,
    data: &T,
    query: &Query<'_>
) -> Result<(), Error> where
    T: Serialize + RestPath<U>, 
[src]

Make PUT request with query parameters.

pub fn patch_with<U, T>(
    &mut self,
    params: U,
    data: &T,
    query: &Query<'_>
) -> Result<(), Error> where
    T: Serialize + RestPath<U>, 
[src]

Make PATCH request with query parameters.

pub fn post_capture<U, T, K>(&mut self, params: U, data: &T) -> Result<K, Error> where
    T: Serialize + RestPath<U>,
    K: DeserializeOwned
[src]

Make a POST request and capture returned body.

pub fn put_capture<U, T, K>(&mut self, params: U, data: &T) -> Result<K, Error> where
    T: Serialize + RestPath<U>,
    K: DeserializeOwned
[src]

Make a PUT request and capture returned body.

pub fn post_capture_with<U, T, K>(
    &mut self,
    params: U,
    data: &T,
    query: &Query<'_>
) -> Result<K, Error> where
    T: Serialize + RestPath<U>,
    K: DeserializeOwned
[src]

Make a POST request with query parameters and capture returned body.

pub fn put_capture_with<U, T, K>(
    &mut self,
    params: U,
    data: &T,
    query: &Query<'_>
) -> Result<K, Error> where
    T: Serialize + RestPath<U>,
    K: DeserializeOwned
[src]

Make a PUT request with query parameters and capture returned body.

pub fn delete<U, T>(&mut self, params: U) -> Result<(), Error> where
    T: RestPath<U>, 
[src]

Make a DELETE request.

pub fn delete_with<U, T>(
    &mut self,
    params: U,
    data: &T,
    query: &Query<'_>
) -> Result<(), Error> where
    T: Serialize + RestPath<U>, 
[src]

Make a DELETE request with query and body.

Auto Trait Implementations

Blanket Implementations

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

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

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

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

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<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.