Skip to main content

StageStore

Trait StageStore 

Source
pub trait StageStore {
Show 13 methods // Required methods fn put(&mut self, stage: Stage) -> Result<StageId, StoreError>; fn upsert(&mut self, stage: Stage) -> Result<StageId, StoreError>; fn remove(&mut self, id: &StageId) -> Result<(), StoreError>; fn get(&self, id: &StageId) -> Result<Option<&Stage>, StoreError>; fn contains(&self, id: &StageId) -> bool; fn list(&self, lifecycle: Option<&StageLifecycle>) -> Vec<&Stage>; fn update_lifecycle( &mut self, id: &StageId, lifecycle: StageLifecycle, ) -> Result<(), StoreError>; fn stats(&self) -> StoreStats; // Provided methods fn get_owned(&self, id: &StageId) -> Result<Option<Stage>, StoreError> { ... } fn list_owned(&self, lifecycle: Option<&StageLifecycle>) -> Vec<Stage> { ... } fn find_by_name(&self, name: &str) -> Vec<&Stage> { ... } fn get_by_signature(&self, signature_id: &SignatureId) -> Option<&Stage> { ... } fn active_stages_with_signature( &self, signature_id: &SignatureId, ) -> Vec<&Stage> { ... }
}
Expand description

Abstraction over stage storage.

Required Methods§

Source

fn put(&mut self, stage: Stage) -> Result<StageId, StoreError>

Source

fn upsert(&mut self, stage: Stage) -> Result<StageId, StoreError>

Insert a stage, replacing any existing stage with the same ID. Used to upgrade unsigned stdlib stages after signing is added.

Source

fn remove(&mut self, id: &StageId) -> Result<(), StoreError>

Remove a stage entirely. Returns Ok(()) whether or not the stage existed.

Source

fn get(&self, id: &StageId) -> Result<Option<&Stage>, StoreError>

Source

fn contains(&self, id: &StageId) -> bool

Source

fn list(&self, lifecycle: Option<&StageLifecycle>) -> Vec<&Stage>

Source

fn update_lifecycle( &mut self, id: &StageId, lifecycle: StageLifecycle, ) -> Result<(), StoreError>

Source

fn stats(&self) -> StoreStats

Provided Methods§

Source

fn get_owned(&self, id: &StageId) -> Result<Option<Stage>, StoreError>

Return an owned clone of the stage. Useful for async contexts where holding a borrow across lock boundaries is not permitted.

Source

fn list_owned(&self, lifecycle: Option<&StageLifecycle>) -> Vec<Stage>

Return owned clones of all matching stages.

Source

fn find_by_name(&self, name: &str) -> Vec<&Stage>

Find all stages whose metadata name field matches exactly. Used by graph loaders so composition files can reference stages by their human-authored name instead of their 8-char content-hash prefix. Returns every match across all lifecycles; callers typically filter for Active.

Source

fn get_by_signature(&self, signature_id: &SignatureId) -> Option<&Stage>

Look up the Active stage for a given SignatureId. This is the M2 “resolve signature to latest implementation” pathway: a graph that pins a stage by signature_id gets whichever implementation is Active today.

Determinism. When multiple Active stages share a signature (which a well-behaved store prevents via the stage add deprecation path, but which can happen transiently), this returns the stage with the lexicographically-smallest implementation ID. A “first match” would be nondeterministic under HashMap-backed stores.

Callers that need to distinguish the “zero matches” and “many matches” cases should use [active_stages_with_signature] and inspect the length.

Source

fn active_stages_with_signature( &self, signature_id: &SignatureId, ) -> Vec<&Stage>

Return every Active stage whose signature_id matches. Ordered lexicographically by implementation ID so iteration is stable across HashMap-backed stores.

This is the diagnostic surface: a well-behaved store should return at most one entry here. A call that returns more is a signal that the “≤1 Active per signature” invariant has been broken — typically by a direct store.put + lifecycle change that bypassed the stage add deprecation path. The resolver uses this helper to warn on multi-match rather than silently picking one.

Implementors§