[−][src]Struct restson::RestClient
REST client to make HTTP GET and POST requests.
Methods
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_timeout(&mut self, timeout: Duration)
[src]
Set request timeout
pub fn set_header(
&mut self,
name: &'static str,
value: &str
) -> Result<(), Error>
[src]
&mut self,
name: &'static str,
value: &str
) -> Result<(), Error>
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]
T: DeserializeOwned + RestPath<U>,
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]
T: DeserializeOwned + RestPath<U>,
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]
T: Serialize + RestPath<U>,
Make a POST request.
pub fn put<U, T>(&mut self, params: U, data: &T) -> Result<(), Error> where
T: Serialize + RestPath<U>,
[src]
T: Serialize + RestPath<U>,
Make a PUT request.
pub fn patch<U, T>(&mut self, params: U, data: &T) -> Result<(), Error> where
T: Serialize + RestPath<U>,
[src]
T: Serialize + RestPath<U>,
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]
&mut self,
params: U,
data: &T,
query: &Query
) -> Result<(), Error> where
T: Serialize + RestPath<U>,
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]
&mut self,
params: U,
data: &T,
query: &Query
) -> Result<(), Error> where
T: Serialize + RestPath<U>,
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]
&mut self,
params: U,
data: &T,
query: &Query
) -> Result<(), Error> where
T: Serialize + RestPath<U>,
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]
T: Serialize + RestPath<U>,
K: DeserializeOwned,
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]
T: Serialize + RestPath<U>,
K: DeserializeOwned,
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]
&mut self,
params: U,
data: &T,
query: &Query
) -> Result<K, Error> where
T: Serialize + RestPath<U>,
K: DeserializeOwned,
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]
&mut self,
params: U,
data: &T,
query: &Query
) -> Result<K, Error> where
T: Serialize + RestPath<U>,
K: DeserializeOwned,
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]
T: RestPath<U>,
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]
&mut self,
params: U,
data: &T,
query: &Query
) -> Result<(), Error> where
T: Serialize + RestPath<U>,
Make a DELETE request with query and body.
Auto Trait Implementations
impl !RefUnwindSafe for RestClient
impl Send for RestClient
impl Sync for RestClient
impl Unpin for RestClient
impl !UnwindSafe for RestClient
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,