Skip to main content

DataManager

Struct DataManager 

Source
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

Source

pub fn new() -> Self

Create a DataManager with the default data directory.

Source

pub fn with_dir(dir: impl Into<PathBuf>) -> Self

Create a DataManager with a custom data directory.

Source

pub fn data_dir(&self) -> &Path

The data directory path.

Source

pub fn offline(&self) -> Result<AssistDataPaths, DataError>

Return paths if all data files exist. No network access.

Source

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 if Content-Length or Last-Modified differs from the sidecar. Network failures here are propagated — callers that need offline-tolerant behavior should use Self::offline instead.
  • Else (static file, MD5 matches, or no sidecar to check against) → keep the cached copy.
Source

pub fn clean(&self) -> Result<(), DataError>

Remove the data directory and all its contents.

Trait Implementations§

Source§

impl Default for DataManager

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.