pub struct RequestOptions {
pub headers: Option<HashMap<String, String>>,
pub timeout: Option<Duration>,
}
Expand description
Options for controlling HTTP requests.
This struct provides a flexible interface for configuring individual HTTP requests without modifying the client’s default settings.
§Examples
Adding custom headers to a specific request:
use hyper_custom_cert::{HttpClient, RequestOptions};
use std::collections::HashMap;
// Create request-specific headers
let mut headers = HashMap::new();
headers.insert("x-request-id".to_string(), "123456".to_string());
// Create request options with these headers
let options = RequestOptions::new()
.with_headers(headers);
// Make request with custom options
let client = HttpClient::new();
let _response = client.request_with_options("https://example.com", Some(options)).await;
Fields§
§headers: Option<HashMap<String, String>>
Headers to add to this specific request
timeout: Option<Duration>
Override the client’s default timeout for this request
Implementations§
Source§impl RequestOptions
impl RequestOptions
Sourcepub fn with_headers(self, headers: HashMap<String, String>) -> Self
pub fn with_headers(self, headers: HashMap<String, String>) -> Self
Add custom headers to this request.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Override the client’s default timeout for this request.
Trait Implementations§
Source§impl Clone for RequestOptions
impl Clone for RequestOptions
Source§fn clone(&self) -> RequestOptions
fn clone(&self) -> RequestOptions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Default for RequestOptions
impl Default for RequestOptions
Source§fn default() -> RequestOptions
fn default() -> RequestOptions
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for RequestOptions
impl RefUnwindSafe for RequestOptions
impl Send for RequestOptions
impl Sync for RequestOptions
impl Unpin for RequestOptions
impl UnwindSafe for RequestOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more