Skip to main content

TemplateCatalog

Struct TemplateCatalog 

Source
pub struct TemplateCatalog { /* private fields */ }
Expand description

The on-disk template catalog: one atomically-replaced JSON per name.

Implementations§

Source§

impl TemplateCatalog

Source

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.

Source

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.

Source

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).

Source

pub fn resolve( &self, reference: &str, ) -> Result<ResolvedTemplate, SnapshotError>

Resolve a name or name:version reference.

Source

pub fn list(&self) -> Result<Vec<(String, TemplateEntry)>, SnapshotError>

Every catalog row: per name (lexical order), published versions in publish order, then the draft.

Source

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).

Source

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.

Source

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.

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more