pub struct ModelStore { /* private fields */ }Expand description
Handle to a model store rooted at one $MODELS_HOME.
Cheap to construct (just resolves paths). All disk creation is lazy: directories are made on first write.
Implementations§
Source§impl ModelStore
impl ModelStore
Sourcepub fn open(root: impl Into<PathBuf>) -> Self
pub fn open(root: impl Into<PathBuf>) -> Self
Open a store rooted at root. Resolves ~ to the home dir.
Sourcepub fn at_platform_default() -> Self
pub fn at_platform_default() -> Self
Open the store at the platform default location.
Sourcepub fn blob_path(&self, sha256_hex: &str) -> PathBuf
pub fn blob_path(&self, sha256_hex: &str) -> PathBuf
Path to the blobs/sha256/<aa>/<full-hash>/data blob for
a SHA-256 hex string. Does NOT check existence.
Sourcepub fn partial_path(&self, sha256_hex: &str) -> PathBuf
pub fn partial_path(&self, sha256_hex: &str) -> PathBuf
Path to the in-progress data.tmp for a download. Lives in
a .partial-<hash> sibling so abandoned downloads are
trivially distinguishable from finalised blobs.
Sourcepub fn manifest_path(&self, name: &str) -> PathBuf
pub fn manifest_path(&self, name: &str) -> PathBuf
Path to a manifest by name.
Sourcepub fn lock_path(&self, name: &str) -> PathBuf
pub fn lock_path(&self, name: &str) -> PathBuf
Path to the advisory lock file for name. Producers hold an
exclusive lock on this file across blob-write + manifest-write
to keep two daemons from racing on the same name.
Sourcepub fn quarantine_dir(&self) -> PathBuf
pub fn quarantine_dir(&self) -> PathBuf
Directory where bad blobs are quarantined. Per ADR 0011 we keep these for forensic inspection rather than deleting them.
Sourcepub fn read_manifest(&self, name: &str) -> Result<Option<Manifest>>
pub fn read_manifest(&self, name: &str) -> Result<Option<Manifest>>
Read a manifest by name. Returns Ok(None) if absent so
callers can branch on present/missing without parsing IO
kinds.
Sourcepub fn write_manifest(&self, manifest: &Manifest) -> Result<PathBuf>
pub fn write_manifest(&self, manifest: &Manifest) -> Result<PathBuf>
Write a manifest atomically: write to <path>.tmp, then
rename. The blob it references must already exist on disk —
callers are expected to write the blob first.
Sourcepub fn quarantine(&self, src: &Path, reason: &str) -> Result<PathBuf>
pub fn quarantine(&self, src: &Path, reason: &str) -> Result<PathBuf>
Move a bad-bytes file into the quarantine dir under a timestamped name. Returns the new path.
Sourcepub fn ensure_layout(&self) -> Result<()>
pub fn ensure_layout(&self) -> Result<()>
Ensure the on-disk skeleton (blobs/, manifests/,
locks/) exists. Idempotent.
Trait Implementations§
Source§impl Clone for ModelStore
impl Clone for ModelStore
Source§fn clone(&self) -> ModelStore
fn clone(&self) -> ModelStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more