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§
Sourcetype State: Clone + Serialize + DeserializeOwned + Send + Sync + 'static
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.
Required Methods§
Sourcefn ecosystem(&self) -> &'static str
fn ecosystem(&self) -> &'static str
Short ecosystem identifier (e.g. "cargo", "npm"). Used
for routing by gen-cli + substrate emitters.
Sourcefn current_state(&self, root: &Path) -> Self::State
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.
Sourcefn requires_operator_action(&self, state: &Self::State) -> bool
fn requires_operator_action(&self, state: &Self::State) -> bool
Adapter-canonical projection: does this state require explicit operator action before substrate can build?
Sourcefn is_locked(&self, state: &Self::State) -> bool
fn is_locked(&self, state: &Self::State) -> bool
Adapter-canonical projection: is this state the byte-equal “committed snapshot matches current source” condition?
Sourcefn is_missing_lock(&self, state: &Self::State) -> bool
fn is_missing_lock(&self, state: &Self::State) -> bool
Adapter-canonical projection: is the source-side lockfile (Cargo.lock / package-lock.json / etc.) missing?
Sourcefn snapshot(&self, root: &Path) -> Result<(), LockError>
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".