pub struct TemplateCatalog { /* private fields */ }Expand description
The on-disk template catalog: one atomically-replaced JSON per name.
Implementations§
Source§impl TemplateCatalog
impl TemplateCatalog
Sourcepub fn new(data_dir: &str) -> TemplateCatalog
pub fn new(data_dir: &str) -> TemplateCatalog
Create a catalog rooted under data_dir. The directory is created
lazily on first write; a missing directory reads as an empty catalog.
Sourcepub fn put_draft(
&self,
name: &str,
entry: TemplateEntry,
) -> Result<PutDraftOutcome, SnapshotError>
pub fn put_draft( &self, name: &str, entry: TemplateEntry, ) -> Result<PutDraftOutcome, SnapshotError>
Install entry as the draft for name, displacing any previous
draft. The stored entry’s version is forced empty.
Sourcepub fn publish(
&self,
name: &str,
version: &str,
) -> Result<PublishOutcome, SnapshotError>
pub fn publish( &self, name: &str, version: &str, ) -> Result<PublishOutcome, SnapshotError>
Freeze the current draft as immutable version.
Idempotent against retries: re-publishing an existing version succeeds
when there is no draft (the earlier attempt committed) or when the
draft’s digest matches the published content — releasing that draft’s
exclusively-owned artifacts; a digest clash is
SnapshotError::TemplateVersionExists (the divergent draft survives for
publishing under a new version, and a later put_draft releases it).
Sourcepub fn resolve(
&self,
reference: &str,
) -> Result<ResolvedTemplate, SnapshotError>
pub fn resolve( &self, reference: &str, ) -> Result<ResolvedTemplate, SnapshotError>
Resolve a name or name:version reference.
Sourcepub fn list(&self) -> Result<Vec<(String, TemplateEntry)>, SnapshotError>
pub fn list(&self) -> Result<Vec<(String, TemplateEntry)>, SnapshotError>
Every catalog row: per name (lexical order), published versions in publish order, then the draft.
Sourcepub fn delete(
&self,
reference: &str,
) -> Result<ReleasedArtifacts, SnapshotError>
pub fn delete( &self, reference: &str, ) -> Result<ReleasedArtifacts, SnapshotError>
Delete a template version (name:version) or a whole template with
all its versions and its draft (name).
Sourcepub fn references_snapshot(
&self,
snapshot_id: &str,
) -> Result<bool, SnapshotError>
pub fn references_snapshot( &self, snapshot_id: &str, ) -> Result<bool, SnapshotError>
True when any catalog entry references snapshot_id as its warm
artifact. The checkpoint surface’s deletion guard keys on this so an
orphaned template-labeled snapshot (record gone after a failed
post-commit cleanup) stays reclaimable via DeleteSnapshot.
Sourcepub fn rootfs_paths(&self) -> Result<BTreeSet<PathBuf>, SnapshotError>
pub fn rootfs_paths(&self) -> Result<BTreeSet<PathBuf>, SnapshotError>
Rootfs images that catalog entries need to stay bootable — a pin
source for the converted-rootfs cache sweep, alongside
SnapshotCatalog::referenced_rootfs_paths.