pub struct HubCache { /* private fields */ }Expand description
The local cache directory. See the module docs.
Implementations§
Source§impl HubCache
impl HubCache
Sourcepub fn from_env_or_default() -> Self
pub fn from_env_or_default() -> Self
$DSPK_HUB_DIR, else <user cache>/dspk/hub.
pub fn new(root_dir: impl Into<PathBuf>) -> Self
pub fn root_dir(&self) -> &Path
pub fn index_path(&self) -> PathBuf
Sourcepub fn artifact_dir(&self, artifact: &Artifact) -> PathBuf
pub fn artifact_dir(&self, artifact: &Artifact) -> PathBuf
<root>/models/<family>/<slug>/.
Sourcepub fn load_index(&self) -> Result<HubCacheIndex>
pub fn load_index(&self) -> Result<HubCacheIndex>
index.json, or an empty index when there is none.
pub fn save_index(&self, index: &HubCacheIndex) -> Result<()>
Sourcepub fn record_installed(
&self,
artifact: &Artifact,
sha256: &str,
size_bytes: u64,
) -> Result<()>
pub fn record_installed( &self, artifact: &Artifact, sha256: &str, size_bytes: u64, ) -> Result<()>
Records a verified download in index.json.
Sourcepub fn status(&self, artifact: &Artifact) -> ArtifactStatus
pub fn status(&self, artifact: &Artifact) -> ArtifactStatus
Status from index.json and the file’s size (no hashing; see Self::verify).
Sourcepub fn verify(
&self,
artifact: &Artifact,
) -> Result<(ArtifactStatus, Option<String>)>
pub fn verify( &self, artifact: &Artifact, ) -> Result<(ArtifactStatus, Option<String>)>
Re-hashes the cached file: Ok(status) with Installed only when hash and size match.
Trait Implementations§
Auto Trait Implementations§
impl Forget for HubCache
impl Freeze for HubCache
impl Move for HubCache
impl RefUnwindSafe for HubCache
impl Send for HubCache
impl Sync for HubCache
impl Unpin for HubCache
impl UnsafeUnpin for HubCache
impl UnwindSafe for HubCache
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