pub struct ToolCatalog { /* private fields */ }Expand description
Inventory of all locally known capabilities, keyed by stable ToolId
in deterministic order, with a generation that advances on every mutation.
Implementations§
Source§impl ToolCatalog
impl ToolCatalog
pub fn empty() -> Self
Sourcepub fn from_registry(registry: &ToolRegistry) -> Result<Self, CatalogError>
pub fn from_registry(registry: &ToolRegistry) -> Result<Self, CatalogError>
Read-only snapshot of the catalog integrated into a live registry.
Kept as a compatibility shim over super::ToolRegistry::catalog;
the registry maintains its catalog through every construction and
mutation path, so this is a pure read with no process start, network
access, schema exposure, or execution grant.
pub fn generation(&self) -> CatalogGeneration
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn get(&self, id: &ToolId) -> Option<&CapabilityRecord>
Sourcepub fn iter(&self) -> impl Iterator<Item = &CapabilityRecord>
pub fn iter(&self) -> impl Iterator<Item = &CapabilityRecord>
Iterate records in deterministic ToolId order.
Sourcepub fn insert(&mut self, record: CapabilityRecord) -> Result<(), CatalogError>
pub fn insert(&mut self, record: CapabilityRecord) -> Result<(), CatalogError>
Insert one capability. Duplicate IDs fail closed (no silent replacement, no generation advance); generation exhaustion fails closed (no entry change). On success the catalog generation advances by exactly one. The record’s factory is stored, never invoked.
Sourcepub fn upsert(
&mut self,
replaced: Option<&ToolId>,
record: CapabilityRecord,
) -> Result<(), CatalogError>
pub fn upsert( &mut self, replaced: Option<&ToolId>, record: CapabilityRecord, ) -> Result<(), CatalogError>
Insert-or-replace one capability as a single mutation, optionally dropping the entry it shadows (registry replacement by runtime name can change the capability identity; the stale identity must not linger and keep validating old grants).
Occupied-identity safety: if the incoming id is already cataloged and
it is NOT the unchanged identity of the same-runtime-name tool being
replaced (replaced == Some(record.id)), the mutation fails typed
with CatalogError::DuplicateToolId before any entry or generation
change — two distinct runtime names must never silently share one
capability identity, or live tools and catalog would diverge. Fails
closed without touching entries when no new generation is available.
Sourcepub fn rebase_past(
&mut self,
prior: CatalogGeneration,
) -> Result<(), CatalogGenerationOverflow>
pub fn rebase_past( &mut self, prior: CatalogGeneration, ) -> Result<(), CatalogGenerationOverflow>
Advance strictly past both this catalog’s generation and a prior
registry generation. Used when a mutation rebuilds the catalog from
scratch (e.g. disable): the rebuilt catalog must not reuse
generation values already observed, or stale grants could survive.
Trait Implementations§
Source§impl Clone for ToolCatalog
impl Clone for ToolCatalog
Auto Trait Implementations§
impl !RefUnwindSafe for ToolCatalog
impl !UnwindSafe for ToolCatalog
impl Freeze for ToolCatalog
impl Send for ToolCatalog
impl Sync for ToolCatalog
impl Unpin for ToolCatalog
impl UnsafeUnpin for ToolCatalog
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.