pub struct CatalogWriter { /* private fields */ }Expand description
Mutating side of a dynamic tool catalog. Owned by subsystems that
discover or refresh tools at runtime (MCP server manager, skill watcher,
plugin loader). Each upsert, remove,
or replace_all emits a ToolCatalogEvent that
every CatalogReader minted from the same dynamic_catalog call
(or its clones) observes via ToolSource::drain_catalog_events.
Implementations§
Source§impl CatalogWriter
impl CatalogWriter
Sourcepub fn reader(&self) -> CatalogReader
pub fn reader(&self) -> CatalogReader
Mints an additional CatalogReader over the same shared state.
The new reader subscribes from now forward — it does not see events
emitted before this call.
Sourcepub fn upsert(&self, tool: Arc<dyn Tool>)
pub fn upsert(&self, tool: Arc<dyn Tool>)
Inserts or replaces a tool. Emits a single-entry catalog event with
the tool’s name in added (new) or changed (replaced).
Sourcepub fn remove(&self, name: &ToolName) -> bool
pub fn remove(&self, name: &ToolName) -> bool
Removes a tool by name. Emits a catalog event with the name in
removed if it existed.
Sourcepub fn replace_all(&self, tools: impl IntoIterator<Item = Arc<dyn Tool>>)
pub fn replace_all(&self, tools: impl IntoIterator<Item = Arc<dyn Tool>>)
Atomically replaces the entire tool set. Emits one catalog event describing the diff against the previous contents.
Sourcepub fn subscribe(&self) -> Receiver<ToolCatalogEvent>
pub fn subscribe(&self) -> Receiver<ToolCatalogEvent>
Subscribes a fresh broadcast receiver. Lower-level than
CatalogReader — for hosts that consume catalog events directly
rather than through the loop.