Skip to main content

LockLifecyclePrimitive

Trait LockLifecyclePrimitive 

Source
pub trait LockLifecyclePrimitive: Send + Sync {
    type State: Clone + Serialize + DeserializeOwned + Send + Sync + 'static;
    type Diff: Clone + Serialize + DeserializeOwned + Send + Sync + 'static;

    // Required methods
    fn ecosystem(&self) -> &'static str;
    fn current_state(&self, root: &Path) -> Self::State;
    fn requires_operator_action(&self, state: &Self::State) -> bool;
    fn is_locked(&self, state: &Self::State) -> bool;
    fn is_missing_lock(&self, state: &Self::State) -> bool;
    fn snapshot(&self, root: &Path) -> Result<(), LockError>;
    fn update(&self, root: &Path) -> Result<Self::Diff, LockError>;
    fn reset(&self, root: &Path) -> Result<(), LockError>;
}
Expand description

Typed lock-lifecycle primitive — one impl per adapter.

Implementors expose the deterministic-lock contract to substrate’s lockfile-builder + gen-cli’s lock subcommand. Concrete states are adapter-specific; the trait constrains only what substrate needs to dispatch on.

Required Associated Types§

Source

type State: Clone + Serialize + DeserializeOwned + Send + Sync + 'static

Adapter-specific state enum. Must include the canonical four substrates (Unlocked / Locked / Drifted / MissingLock) reachable via the is_* methods below. Each adapter is free to add more states (workspace-protocol drift, registry-pin staleness, etc.) — substrate dispatches via the canonical flags so extra states don’t break the gate.

Source

type Diff: Clone + Serialize + DeserializeOwned + Send + Sync + 'static

Adapter-specific structural diff. Substrate emitters (release-notes builders, PR-body renderers) consume this type directly.

Required Methods§

Source

fn ecosystem(&self) -> &'static str

Short ecosystem identifier (e.g. "cargo", "npm"). Used for routing by gen-cli + substrate emitters.

Source

fn current_state(&self, root: &Path) -> Self::State

Read the current state from the filesystem. Pure — same inputs always yield the same output. No subprocess calls other than hashing the lockfile.

Source

fn requires_operator_action(&self, state: &Self::State) -> bool

Adapter-canonical projection: does this state require explicit operator action before substrate can build?

Source

fn is_locked(&self, state: &Self::State) -> bool

Adapter-canonical projection: is this state the byte-equal “committed snapshot matches current source” condition?

Source

fn is_missing_lock(&self, state: &Self::State) -> bool

Adapter-canonical projection: is the source-side lockfile (Cargo.lock / package-lock.json / etc.) missing?

Source

fn snapshot(&self, root: &Path) -> Result<(), LockError>

Explicit operator snapshot — write the committed lock artifact (Cargo.build-spec.json / equivalent). Errors when the state is MissingLock or when the snapshot can’t be written.

Source

fn update(&self, root: &Path) -> Result<Self::Diff, LockError>

Explicit operator update — regenerate the committed lock + compute the typed diff against the previous snapshot. Returns the typed diff so callers can render it.

Source

fn reset(&self, root: &Path) -> Result<(), LockError>

Explicit operator reset — delete the committed lock artifact (return to the Unlocked state). Errors only on filesystem failure (a missing artifact is treated as success — idempotent).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§