pub trait RequestOptionsBuilder: RequestBuilder {
// Required methods
fn with_idempotency(self, v: bool) -> Self;
fn with_user_agent<V: Into<String>>(self, v: V) -> Self;
fn with_attempt_timeout<V: Into<Duration>>(self, v: V) -> Self;
fn with_retry_policy<V: Into<RetryPolicyArg>>(self, v: V) -> Self;
fn with_backoff_policy<V: Into<BackoffPolicyArg>>(self, v: V) -> Self;
fn with_retry_throttler<V: Into<RetryThrottlerArg>>(self, v: V) -> Self;
fn with_polling_error_policy<V: Into<PollingErrorPolicyArg>>(
self,
v: V,
) -> Self;
fn with_polling_backoff_policy<V: Into<PollingBackoffPolicyArg>>(
self,
v: V,
) -> Self;
// Provided methods
fn with_quota_project<V: Into<String>>(self, _v: V) -> Self
where Self: Sized { ... }
fn with_custom_header(self, name: HeaderName, value: HeaderValue) -> Self
where Self: Sized { ... }
fn with_request_stream_channel_capacity(self, _capacity: usize) -> Self
where Self: Sized { ... }
}Expand description
Implementations of this trait provide setters to configure request options.
The Google Cloud Client Libraries for Rust provide a builder for each RPC. These builders can be used to set the request parameters, e.g., the name of the resource targeted by the RPC, as well as any options affecting the request, such as additional headers or timeouts.
Required Methods§
Sourcefn with_idempotency(self, v: bool) -> Self
fn with_idempotency(self, v: bool) -> Self
If v is true, treat the RPC underlying this method as idempotent.
Sourcefn with_user_agent<V: Into<String>>(self, v: V) -> Self
fn with_user_agent<V: Into<String>>(self, v: V) -> Self
Set the user agent header.
Sourcefn with_attempt_timeout<V: Into<Duration>>(self, v: V) -> Self
fn with_attempt_timeout<V: Into<Duration>>(self, v: V) -> Self
Sets the per-attempt timeout.
When using a retry loop, this affects the timeout for each attempt. The overall timeout for a request is set by the retry policy.
Sourcefn with_retry_policy<V: Into<RetryPolicyArg>>(self, v: V) -> Self
fn with_retry_policy<V: Into<RetryPolicyArg>>(self, v: V) -> Self
Sets the retry policy configuration.
Sourcefn with_backoff_policy<V: Into<BackoffPolicyArg>>(self, v: V) -> Self
fn with_backoff_policy<V: Into<BackoffPolicyArg>>(self, v: V) -> Self
Sets the backoff policy configuration.
Sourcefn with_retry_throttler<V: Into<RetryThrottlerArg>>(self, v: V) -> Self
fn with_retry_throttler<V: Into<RetryThrottlerArg>>(self, v: V) -> Self
Sets the retry throttler configuration.
Sourcefn with_polling_error_policy<V: Into<PollingErrorPolicyArg>>(self, v: V) -> Self
fn with_polling_error_policy<V: Into<PollingErrorPolicyArg>>(self, v: V) -> Self
Sets the polling error policy configuration.
Sourcefn with_polling_backoff_policy<V: Into<PollingBackoffPolicyArg>>(
self,
v: V,
) -> Self
fn with_polling_backoff_policy<V: Into<PollingBackoffPolicyArg>>( self, v: V, ) -> Self
Sets the polling backoff policy configuration.
Provided Methods§
Sourcefn with_quota_project<V: Into<String>>(self, _v: V) -> Selfwhere
Self: Sized,
fn with_quota_project<V: Into<String>>(self, _v: V) -> Selfwhere
Self: Sized,
Sets the quota project for the request.
This adds the x-goog-user-project header to the request. Note that
setting this option overrides a credentials’ quota project.
Sourcefn with_custom_header(self, name: HeaderName, value: HeaderValue) -> Selfwhere
Self: Sized,
fn with_custom_header(self, name: HeaderName, value: HeaderValue) -> Selfwhere
Self: Sized,
Injects a custom HTTP header (or gRPC metadata) into this specific request.
This method will ignore attempts to set system headers used by the client
library. These include: user-agent, authorization,
x-goog-api-key, x-goog-api-client, x-goog-user-project,
and x-goog-request-params.
Callers who want to configure respective system headers should use the dedicated methods instead:
user-agent: Usewith_user_agent(or globally viaClientBuilder).x-goog-user-project: Usewith_quota_project.authorizationandx-goog-api-key: Configure globally viaClientBuilder::with_credentials.
Note that x-goog-api-client and x-goog-request-params are dynamically auto-generated by the SDK
for telemetry and routing, and cannot be customized by callers.
§Repeated Headers
Under HTTP RFC 9110 (Section 5.3), standard repeated headers (e.g. Cache-Control, Accept, or Allow)
are defined as comma-separated lists. Callers can supply repeated values natively as a single
comma-separated HeaderValue:
use http::header::{HeaderName, HeaderValue};
fn sample<T: RequestOptionsBuilder>(builder: T) -> T {
builder.with_custom_header(
HeaderName::from_static("cache-control"),
HeaderValue::from_static("no-cache, no-store"),
)
}Sourcefn with_request_stream_channel_capacity(self, _capacity: usize) -> Selfwhere
Self: Sized,
fn with_request_stream_channel_capacity(self, _capacity: usize) -> Selfwhere
Self: Sized,
Sets the buffer capacity of the internal request channel for streaming RPCs.
Valid values are between 1 and usize::MAX >> 3. The default
capacity is 16. Values outside this range will be clamped.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<T> RequestOptionsBuilder for Twhere
T: RequestBuilder,
Implements the sealed RequestOptionsBuilder trait.