pub trait RequestModifiers: RequestInfo {
// Provided methods
fn create_endpoint(endpoint: &str) -> String { ... }
fn add_header_if(
request_builder: RequestBuilder,
key: &str,
value: &str,
closure: impl FnOnce() -> bool,
) -> RequestBuilder { ... }
}
Expand description
This trait provides methods for modifying the struct in a specific way:
Provided Methods§
Sourcefn create_endpoint(endpoint: &str) -> String
fn create_endpoint(endpoint: &str) -> String
Sourcefn add_header_if(
request_builder: RequestBuilder,
key: &str,
value: &str,
closure: impl FnOnce() -> bool,
) -> RequestBuilder
fn add_header_if( request_builder: RequestBuilder, key: &str, value: &str, closure: impl FnOnce() -> bool, ) -> RequestBuilder
Conditionally adds a header to the given RequestBuilder
based on the result of a closure.
If the closure returns true
, the specified header with the provided key
and value
will be added to the request. If the closure returns false
, no changes will be made
to the request.
§Arguments
request_builder
- TheRequestBuilder
to add the header to.key
- The key of the header to be added.value
- The value of the header to be added.closure
- A closure that determines whether the header should be added. It should take no arguments and return a boolean value.
§Returns
The modified RequestBuilder
with the header added if the closure returns true
,
otherwise the original RequestBuilder
without any modifications.
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.