pub struct Client { /* private fields */ }Expand description
The runtime session: it holds the auth flow, HTTP client, base-URL configuration, and retry policy shared by every manager.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(auth: Auth) -> Client
pub fn new(auth: Auth) -> Client
Build a runtime session for an authentication flow, with the default Box base URLs, a 60s HTTP timeout, and five retries.
Sourcepub fn with_max_retries(self, n: u32) -> Client
pub fn with_max_retries(self, n: u32) -> Client
Override how many times a retriable failure is retried (fluent).
Sourcepub fn with_http_client(self, http: Client) -> Client
pub fn with_http_client(self, http: Client) -> Client
Override the reqwest::Client used for API requests (fluent) — e.g. to
inject an instrumented transport instead of the internally built default.
Sourcepub fn with_header(self, name: &str, value: &str) -> Client
pub fn with_header(self, name: &str, value: &str) -> Client
Add a header sent with every request from this client (fluent) — e.g.
a tracing or User-Agent header an embedding application wants on
every call. Replaces any prior default with the same name
(case-insensitive). A header set on an individual Request (via the
free with_header) takes precedence over a same-named default.
Sourcepub fn with_base_url(self, name: &str, base: &str) -> Client
pub fn with_base_url(self, name: &str, base: &str) -> Client
Override one base-URL class for custom deployments (fluent).
Sourcepub fn base_url(&self, name: &str) -> String
pub fn base_url(&self, name: &str) -> String
The configured base URL for a D-106 class, without a trailing slash.
Sourcepub async fn access_token(&self) -> Result<String, Error>
pub async fn access_token(&self) -> Result<String, Error>
A valid access token for the configured auth flow.
Sourcepub fn new_request(&self, method: &str, url: &str) -> Request
pub fn new_request(&self, method: &str, url: &str) -> Request
Create a request envelope for a method and fully built URL.
Sourcepub async fn fetch(&self, request: Request) -> Result<Response, Error>
pub async fn fetch(&self, request: Request) -> Result<Response, Error>
Execute the request with retries: exponential backoff + full jitter, a single 401 token refresh, and Retry-After (as a floor) on 429/5xx.
Retries are gated on idempotency: a 429 means the request was rate-limited and never processed, so it retries for every method; a transport error or 5xx may have already committed a write, so those retry only for idempotent methods (GET/HEAD/PUT/DELETE/…). The 401 refresh applies to every method.