Skip to main content

RequestOptions

Struct RequestOptions 

Source
pub struct RequestOptions {
Show 13 fields pub headers: HeaderMap, pub user_agent: Option<HeaderValue>, pub context: RequestContext, pub idempotency_key: Option<String>, pub timeout: Option<Duration>, pub idle_timeout: Option<Duration>, pub extra_query: Vec<(String, String)>, pub stream_reconnect: Option<StreamReconnectPolicy>, pub cancellation: Option<CancellationToken>, pub request_transform: Option<Arc<dyn RequestTransform>>, pub provider_request: ProviderRequestOptions, pub audit_config: Option<AuditConfig>, pub response_limits: ResponseLimits,
}
Expand description

Per-request transport options.

Fields§

§headers: HeaderMap

Request-level headers, subject to HeaderPolicy protection checks.

§user_agent: Option<HeaderValue>

Per-request User-Agent override.

§context: RequestContext

Correlation identifiers and attributes exposed to header injectors.

§idempotency_key: Option<String>

Adds an idempotency-key header and enables automatic replay of idempotent requests.

§timeout: Option<Duration>

Total request timeout covering the whole exchange.

§idle_timeout: Option<Duration>

Maximum time between bytes while reading an SSE stream.

§extra_query: Vec<(String, String)>

Additional query parameters appended to the endpoint URL.

Duplicate names are preserved. Protocol-reserved names are validated by the adapter before the request is sent.

§stream_reconnect: Option<StreamReconnectPolicy>

Opt-in reconnect policy for a stream after it has started.

§cancellation: Option<CancellationToken>

Cooperative cancellation shared by all attempts and stream reads.

§request_transform: Option<Arc<dyn RequestTransform>>

Optional transform applied once before capability gating and normalization.

§provider_request: ProviderRequestOptions

Typed provider request switches for this logical request.

§audit_config: Option<AuditConfig>

Per-request override for transport audit switches.

§response_limits: ResponseLimits

Decoded response budgets shared across attempts and reconnects.

Implementations§

Source§

impl RequestOptions

Source

pub fn new() -> Self

Creates empty per-request options.

Source

pub fn response_limits(self, limits: ResponseLimits) -> Self

Replaces response byte/event budgets and raw/progress settings.

Source

pub fn header( self, name: impl AsRef<str>, value: impl AsRef<str>, ) -> Result<Self>

Adds one request-level header, replacing any existing value with the same name.

§Errors

Returns an error if the name is not a valid HeaderName, the value is not a valid HeaderValue, or the value contains non-ASCII bytes.

Source

pub fn extra_headers(self, headers: HeaderMap) -> Self

Merge a set of request-level headers.

This is an alias for callers that already build a HeaderMap. Header policy and protected-header validation are still applied when the request is sent.

Source

pub fn extra_query( self, name: impl Into<String>, value: impl Into<String>, ) -> Self

Append one query parameter without rewriting the endpoint URL.

Source

pub fn stream_reconnect(self, policy: StreamReconnectPolicy) -> Self

Enables opt-in reconnect for the stream after it has started.

Source

pub fn cancellation(self, token: CancellationToken) -> Self

Attaches a cooperative cancellation token shared by all attempts and stream reads.

Source

pub fn cancellation_token(self, token: CancellationToken) -> Self

Source

pub fn request_transform( self, transform: impl RequestTransform + 'static, ) -> Self

Installs a request transform applied once before capability gating and normalization.

Source

pub fn provider_request(self, provider_request: ProviderRequestOptions) -> Self

Replaces the typed provider request switches for this logical request.

Source

pub fn audit_config(self, audit_config: AuditConfig) -> Self

Overrides the transport-level audit switches for this request.

Source

pub fn user_agent(self, user_agent: impl AsRef<str>) -> Result<Self>

Overrides the User-Agent for this request.

§Errors

Returns an error if the value is not a valid HeaderValue or contains non-ASCII bytes.

Source

pub fn context(self, context: RequestContext) -> Self

Replaces the per-request context.

Source

pub fn idempotency_key(self, key: impl Into<String>) -> Self

Sets the idempotency key sent as idempotency-key.

Source

pub fn timeout(self, timeout: Duration) -> Self

Sets the total request timeout.

Source

pub fn idle_timeout(self, idle_timeout: Duration) -> Self

Sets the maximum time between bytes while reading an SSE stream.

Trait Implementations§

Source§

impl Clone for RequestOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RequestOptions

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RequestOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more