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: HeaderMapRequest-level headers, subject to HeaderPolicy protection checks.
user_agent: Option<HeaderValue>Per-request User-Agent override.
context: RequestContextCorrelation 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: ProviderRequestOptionsTyped provider request switches for this logical request.
audit_config: Option<AuditConfig>Per-request override for transport audit switches.
response_limits: ResponseLimitsDecoded response budgets shared across attempts and reconnects.
Implementations§
Source§impl RequestOptions
impl RequestOptions
Sourcepub fn response_limits(self, limits: ResponseLimits) -> Self
pub fn response_limits(self, limits: ResponseLimits) -> Self
Replaces response byte/event budgets and raw/progress settings.
Sourcepub fn header(
self,
name: impl AsRef<str>,
value: impl AsRef<str>,
) -> Result<Self>
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.
Sourcepub fn extra_headers(self, headers: HeaderMap) -> Self
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.
Sourcepub fn extra_query(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn extra_query( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Append one query parameter without rewriting the endpoint URL.
Sourcepub fn stream_reconnect(self, policy: StreamReconnectPolicy) -> Self
pub fn stream_reconnect(self, policy: StreamReconnectPolicy) -> Self
Enables opt-in reconnect for the stream after it has started.
Sourcepub fn cancellation(self, token: CancellationToken) -> Self
pub fn cancellation(self, token: CancellationToken) -> Self
Attaches a cooperative cancellation token shared by all attempts and stream reads.
Sourcepub fn cancellation_token(self, token: CancellationToken) -> Self
pub fn cancellation_token(self, token: CancellationToken) -> Self
Alias for RequestOptions::cancellation.
Sourcepub fn request_transform(
self,
transform: impl RequestTransform + 'static,
) -> Self
pub fn request_transform( self, transform: impl RequestTransform + 'static, ) -> Self
Installs a request transform applied once before capability gating and normalization.
Sourcepub fn provider_request(self, provider_request: ProviderRequestOptions) -> Self
pub fn provider_request(self, provider_request: ProviderRequestOptions) -> Self
Replaces the typed provider request switches for this logical request.
Sourcepub fn audit_config(self, audit_config: AuditConfig) -> Self
pub fn audit_config(self, audit_config: AuditConfig) -> Self
Overrides the transport-level audit switches for this request.
Sourcepub fn user_agent(self, user_agent: impl AsRef<str>) -> Result<Self>
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.
Sourcepub fn context(self, context: RequestContext) -> Self
pub fn context(self, context: RequestContext) -> Self
Replaces the per-request context.
Sourcepub fn idempotency_key(self, key: impl Into<String>) -> Self
pub fn idempotency_key(self, key: impl Into<String>) -> Self
Sets the idempotency key sent as idempotency-key.
Sourcepub fn idle_timeout(self, idle_timeout: Duration) -> Self
pub fn idle_timeout(self, idle_timeout: Duration) -> Self
Sets the maximum time between bytes while reading an SSE stream.