pub struct DataManager { /* private fields */ }Expand description
Manages downloading and caching of the files ASSIST needs.
Files are stored in a local data directory. Default location is
$ASSIST_DATA_DIR if set, otherwise $XDG_CACHE_HOME/assist-rs/ or
~/.cache/assist-rs/.
Implementations§
Source§impl DataManager
impl DataManager
Sourcepub fn with_dir(dir: impl Into<PathBuf>) -> Self
pub fn with_dir(dir: impl Into<PathBuf>) -> Self
Create a DataManager with a custom data directory.
Sourcepub fn offline(&self) -> Result<AssistDataPaths, DataError>
pub fn offline(&self) -> Result<AssistDataPaths, DataError>
Return paths if all data files exist. No network access.
Sourcepub fn ensure_ready(&self) -> Result<AssistDataPaths, DataError>
pub fn ensure_ready(&self) -> Result<AssistDataPaths, DataError>
Ensure all three files exist, downloading any that are missing, locally corrupted, or stale upstream.
For each file:
- If the file is missing → download.
- Else if a sidecar exists, compare the local file’s MD5 against the stored MD5. Mismatch implies local corruption or tampering → re-download. An error computing the MD5 (e.g. unreadable file) is propagated, not swallowed.
- Else if the file is non-static (e.g.
obscodes_extended.json), HEAD the remote and re-download ifContent-LengthorLast-Modifieddiffers from the sidecar. Network failures here are propagated — callers that need offline-tolerant behavior should useSelf::offlineinstead. - Else (static file, MD5 matches, or no sidecar to check against) → keep the cached copy.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DataManager
impl RefUnwindSafe for DataManager
impl Send for DataManager
impl Sync for DataManager
impl Unpin for DataManager
impl UnsafeUnpin for DataManager
impl UnwindSafe for DataManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more