pub struct MtgjsonSdkBuilder { /* private fields */ }Expand description
Builder for configuring and constructing an MtgjsonSdk instance.
Use MtgjsonSdk::builder() to obtain a builder, chain configuration
methods, and call build() to create the SDK.
Implementations§
Source§impl MtgjsonSdkBuilder
impl MtgjsonSdkBuilder
Sourcepub fn cache_dir<P: AsRef<Path>>(self, path: P) -> Self
pub fn cache_dir<P: AsRef<Path>>(self, path: P) -> Self
Set a custom cache directory.
If not set, the platform-appropriate default cache directory is used
(e.g. ~/.cache/mtgjson-sdk on Linux, ~/Library/Caches/mtgjson-sdk
on macOS, %LOCALAPPDATA%\mtgjson-sdk on Windows).
Sourcepub fn offline(self, offline: bool) -> Self
pub fn offline(self, offline: bool) -> Self
Enable or disable offline mode.
When offline, the SDK never downloads from the CDN and only uses
previously cached data files. Defaults to false.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Set the HTTP request timeout for CDN downloads.
Defaults to 120 seconds.
Sourcepub fn on_progress<F>(self, f: F) -> Self
pub fn on_progress<F>(self, f: F) -> Self
Set a progress callback for CDN downloads.
The callback receives (filename, bytes_downloaded, total_bytes) and is
called periodically during file downloads. total_bytes is 0 if the
server did not provide a Content-Length header.
Sourcepub fn build(self) -> Result<MtgjsonSdk>
pub fn build(self) -> Result<MtgjsonSdk>
Build the SDK, initializing the cache and DuckDB connection.
This may trigger a version check against the CDN (unless offline mode is enabled) but does not download any data files eagerly – they are fetched lazily on first query.