Skip to main content

ThunderstoreClientBuilder

Struct ThunderstoreClientBuilder 

Source
pub struct ThunderstoreClientBuilder { /* private fields */ }
Expand description

Builder for ThunderstoreClient.

Implementations§

Source§

impl ThunderstoreClientBuilder

Source

pub fn base_url(self, base_url: impl Into<String>) -> Self

Sets the Thunderstore host (default https://thunderstore.io).

Source

pub fn community(self, community: impl Into<String>) -> Self

Sets the community slug — the lowercase, hyphenated identifier in a community’s Thunderstore URL.

Source

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.

Source

pub fn cache_dir(self, cache_dir: impl Into<PathBuf>) -> Self

Sets the cache directory used for the index and downloads.

Source

pub fn progress(self, progress: Arc<dyn ProgressReporter>) -> Self

Sets the progress reporter (default: NoopProgress).

Source

pub fn download_concurrency(self, concurrency: usize) -> Self

Sets the maximum number of concurrent downloads (default 2).

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn max_retries(self, max_retries: u32) -> Self

Convenience for retry: sets only the maximum number of retries, keeping the default backoff.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for ThunderstoreClientBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more