pub struct Call<T> { /* private fields */ }Expand description
A pending call. Await it for the parsed result, or set per-call options first.
Nothing is sent until the call is awaited. Dropping the future cancels the request and any pending retry.
use std::time::Duration;
let models = client
.models()
.list()
.timeout(Duration::from_secs(2))
.max_retries(0)
.with_response()
.await?;
println!("{:?} {:?}", models.request_id, models.data);Implementations§
Source§impl<T> Call<T>
impl<T> Call<T>
Sourcepub fn total_timeout(self, total_timeout: impl Into<Option<Duration>>) -> Self
pub fn total_timeout(self, total_timeout: impl Into<Option<Duration>>) -> Self
Upper bound for the whole call, including credentials, retries and backoff.
Pass None to remove the client’s bound for this call.
Attempts are shortened to fit the time left. A retry is skipped when its backoff would end past the bound, and a retry cut short by the bound returns the previous attempt’s error, such as the 503 that caused the retry.
Sourcepub fn retry(self, retry: RetryPolicy) -> Self
pub fn retry(self, retry: RetryPolicy) -> Self
Retry policy for this call, replacing the client’s.
Sourcepub fn max_retries(self, max_retries: u32) -> Self
pub fn max_retries(self, max_retries: u32) -> Self
Retries after the initial attempt for this call; 0 disables retries.
Applies on top of the client’s policy or the one set with Call::retry.
Sourcepub fn header(self, name: HeaderName, value: HeaderValue) -> Self
pub fn header(self, name: HeaderName, value: HeaderValue) -> Self
Add a header for this call, replacing a default header with the same name.
Authentication, content negotiation and SDK headers cannot be overridden.
Sourcepub fn headers(self, headers: HeaderMap) -> Self
pub fn headers(self, headers: HeaderMap) -> Self
Add headers for this call, replacing earlier values for the same names.
Sourcepub async fn raw(self) -> Result<RawResponse>
pub async fn raw(self) -> Result<RawResponse>
Send the call and return the body without parsing it.
Sourcepub async fn with_response(self) -> Result<WithResponse<T>>
pub async fn with_response(self) -> Result<WithResponse<T>>
Send the call and return the parsed result with response metadata.