pub struct ThunderstoreClientBuilder { /* private fields */ }Expand description
Builder for ThunderstoreClient.
Implementations§
Source§impl ThunderstoreClientBuilder
impl ThunderstoreClientBuilder
Sourcepub fn base_url(self, base_url: impl Into<String>) -> Self
pub fn base_url(self, base_url: impl Into<String>) -> Self
Sets the Thunderstore host (default https://thunderstore.io).
Sourcepub fn community(self, community: impl Into<String>) -> Self
pub fn community(self, community: impl Into<String>) -> Self
Sets the community slug — the lowercase, hyphenated identifier in a community’s Thunderstore URL.
Sourcepub fn package_index_url(self, url: impl Into<String>) -> Self
pub fn package_index_url(self, url: impl Into<String>) -> Self
Overrides the fully composed package-index URL (mainly for tests/mirrors).
When set, this takes precedence over base_url/community composition.
Sourcepub fn cache_dir(self, cache_dir: impl Into<PathBuf>) -> Self
pub fn cache_dir(self, cache_dir: impl Into<PathBuf>) -> Self
Sets the cache directory used for the index and downloads.
Sourcepub fn progress(self, progress: Arc<dyn ProgressReporter>) -> Self
pub fn progress(self, progress: Arc<dyn ProgressReporter>) -> Self
Sets the progress reporter (default: NoopProgress).
Sourcepub fn download_concurrency(self, concurrency: usize) -> Self
pub fn download_concurrency(self, concurrency: usize) -> Self
Sets the maximum number of concurrent downloads (default 2).
Sourcepub fn download_timeout(self, timeout: Duration) -> Self
pub fn download_timeout(self, timeout: Duration) -> Self
Sets the network timeout (default 60s) applied as both the connection timeout and the per-read (idle) timeout — not a deadline on the whole request. A large archive can therefore take arbitrarily long to download as long as data keeps flowing, while a stalled connection still fails promptly.
Sourcepub fn manifest_max_bytes(self, max_bytes: u64) -> Self
pub fn manifest_max_bytes(self, max_bytes: u64) -> Self
Sets the maximum size, in bytes, of the package-index response body (raw
JSON) read into memory. The default is a generous ceiling that accommodates
large community indices; a response whose declared Content-Length or actual
streamed size exceeds it is rejected, bounding memory against an oversized
index from a compromised or misbehaving host. Pass u64::MAX to
effectively disable the cap.
Unless manifest_max_decompressed_bytes
is also set, the cache read-back cap tracks this value, so raising this alone
keeps a downloaded manifest readable back from cache.
Sourcepub fn manifest_max_decompressed_bytes(self, max_bytes: u64) -> Self
pub fn manifest_max_decompressed_bytes(self, max_bytes: u64) -> Self
Sets the maximum decompressed size, in bytes, of the on-disk index cache permitted when reading it back.
By default (when this is left unset) the read cap tracks
manifest_max_bytes, i.e. the download cap. The
interned-bincode cache is always smaller than the JSON it was built from, so
tracking the download cap guarantees any manifest that downloads successfully
can be read back from cache rather than being silently re-downloaded on every
run.
Set this explicitly to bound decode allocation more tightly than the download
cap — e.g. when a cache_dir is shared across mutually-distrusting users and
you want a smaller ceiling. Setting it below what your community’s cache
actually needs will make that cache unreadable (it re-downloads instead), so
size it to your community. Pass u64::MAX to effectively disable the cap.
Sourcepub fn retry(self, policy: RetryPolicy) -> Self
pub fn retry(self, policy: RetryPolicy) -> Self
Sets the retry policy for transient network failures (default: a few
retries with exponential backoff). Retries apply to package downloads and
the index download, only for transient errors (connection/timeout/body,
5xx, 429) — never a 4xx or a terminal error. Pass
RetryPolicy::none to disable retrying.
Sourcepub fn max_retries(self, max_retries: u32) -> Self
pub fn max_retries(self, max_retries: u32) -> Self
Convenience for retry: sets only the maximum number of
retries, keeping the default backoff.
Sourcepub fn download_max_bytes(self, max_bytes: u64) -> Self
pub fn download_max_bytes(self, max_bytes: u64) -> Self
Sets the maximum size, in bytes, of a single package archive download. The
default is a generous ceiling; a download whose declared Content-Length or
actual streamed size exceeds it is rejected with
Error::SizeLimitExceeded, which
bounds disk use against an oversized or runaway body. Pass u64::MAX to
effectively disable the cap.
Sourcepub fn build(self) -> Result<ThunderstoreClient>
pub fn build(self) -> Result<ThunderstoreClient>
Builds the ThunderstoreClient.
§Errors
Returns an error if cache_dir was not set, the community slug is
invalid, or the HTTP client cannot be constructed.