pub struct ClientBuilder { /* private fields */ }Expand description
Builder for Client.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a builder with production defaults: HTTPS, public addresses, TEA 1.0.0.
Sourcepub fn cache_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn cache_dir(self, dir: impl Into<PathBuf>) -> Self
Keep a persistent response cache in dir (experimental; off by default).
GET responses are stored and revalidated with ETag / Last-Modified
conditional requests. The directory is created private (mode 0700, files
0600 on Unix); a symbolic link or a directory open to other users makes
ClientBuilder::build fail. Responses to requests that carried
credentials, Cache-Control: no-store and (by default) private
responses are not stored. Cache contents are never trusted: artifact
bytes are checked against their declared checksums on every use.
See docs/cache.md and CacheConfig for the limits.
Sourcepub fn cache(self, config: CacheConfig) -> Self
pub fn cache(self, config: CacheConfig) -> Self
Enable the cache with explicit settings (experimental).
Sourcepub fn offline(self, offline: bool) -> Self
pub fn offline(self, offline: bool) -> Self
Answer only from the cache and never open a connection (experimental).
A cacheable GET that is not in the cache (or whose entry is older than
CacheConfig::max_age) fails with ClientError::Offline; any other
request fails the same way. Requires ClientBuilder::cache_dir or
ClientBuilder::cache; ClientBuilder::build fails without one.
Sourcepub fn destination_policy(self, policy: DestinationPolicy) -> Self
pub fn destination_policy(self, policy: DestinationPolicy) -> Self
Replace the destination policy.
The default rejects cleartext HTTP, loopback, link-local, and private addresses.
Sourcepub fn supported_versions(self, supported: SupportedApi) -> Self
pub fn supported_versions(self, supported: SupportedApi) -> Self
Versions this client is willing to speak. Build metadata on the server is ignored.
Sourcepub fn api_key(self, key: ApiKey) -> Self
pub fn api_key(self, key: ApiKey) -> Self
API key used at POST /token for origins the caller has explicitly selected.
Discovery does not send this key to endpoints learned from .well-known/tea
unless Self::allow_discovered_credentials is set. A crate::Service
built from a caller-supplied base URL may use the key at that origin.
Sourcepub fn allow_discovered_credentials(self, allow: bool) -> Self
pub fn allow_discovered_credentials(self, allow: bool) -> Self
Allow the API key to be presented to token endpoints chosen by discovery.
Leave this unset when the well-known document is not a trusted source of credential destinations.
Sourcepub fn well_known_fetch_url(self, url: Url) -> Self
pub fn well_known_fetch_url(self, url: Url) -> Self
Fetch the well-known document from this URL instead of https://{tei-domain}/.well-known/tea.
The override is still subject to DestinationPolicy. It exists so tests
and explicitly configured fixtures can supply the document without changing
production URL construction.
Sourcepub fn lenient_versions(self, lenient: bool) -> Self
pub fn lenient_versions(self, lenient: bool) -> Self
Accept API versions that are not exactly a supported one (default false).
When true, /.well-known/tea and /discovery may advertise 1 or
1.0 (read as 1.0.0; the advertised spelling stays in the request
path, so 1 calls /v1/…), and any stable version with the same
major as a supported version is accepted, for example 1.0.1 and
1.1.0 for a client that supports 1.0.0. Pre-releases (1.2.0-rc.1)
are accepted only on an exact match.
Selection order: exact supported versions first (highest version, then priority), then same-major stable versions (highest first). An exact match is never outranked by a version this client was not written for.
Risk: this client’s models were checked against the pinned 1.0.0
schemas only. A server that passes the version check may still send
responses that fail to parse or that are misread. The default (false)
is unchanged from earlier behavior.
Sourcepub fn allow_weak_checksums(self, allow: bool) -> Self
pub fn allow_weak_checksums(self, allow: bool) -> Self
Accept artifact downloads whose only declared checksums use weak algorithms (SHA-1).
Off by default: such a download fails with ClientError::Integrity
and libtea_core::IntegrityOutcome::Weak. When set, a full match is
reported as libtea_core::IntegrityOutcome::Verified and each
libtea_core::ChecksumCheck::weak stays true.
Sourcepub fn ignore_env_proxies(self, ignore: bool) -> Self
pub fn ignore_env_proxies(self, ignore: bool) -> Self
Ignore HTTP_PROXY / HTTPS_PROXY / ALL_PROXY (and lowercase forms).
By default environment proxies are honored. Through a proxy, the
proxy resolves the target hostname, so the DNS-based
DestinationPolicy checks are not enforced for hostnames; only
scheme, userinfo, literal-IP, and redirect checks still apply. Set this
to true to connect directly and keep the DNS checks.
Sourcepub fn add_root_pem(self, pem: impl Into<Vec<u8>>) -> Self
pub fn add_root_pem(self, pem: impl Into<Vec<u8>>) -> Self
Add a PEM trust anchor. System or webpki roots remain in use as well.