Skip to main content

ToolRegistry

Trait ToolRegistry 

Source
pub trait ToolRegistry:
    Send
    + Sync
    + 'static {
    // Required methods
    fn list(&self) -> Vec<Arc<dyn Tool>>;
    fn get(&self, n: &str) -> Option<Arc<dyn Tool>>;
    fn register(&self, t: Arc<dyn Tool>) -> Disposer;
    fn replace(&self, t: Arc<dyn Tool>) -> Disposer;
    fn remove(&self, name: &str) -> usize;

    // Provided methods
    fn names(&self) -> Vec<String> { ... }
    fn len(&self) -> usize { ... }
    fn is_empty(&self) -> bool { ... }
}

Required Methods§

Source

fn list(&self) -> Vec<Arc<dyn Tool>>

Source

fn get(&self, n: &str) -> Option<Arc<dyn Tool>>

Source

fn register(&self, t: Arc<dyn Tool>) -> Disposer

Add a tool, returning a handle that can withdraw exactly this registration.

Source

fn replace(&self, t: Arc<dyn Tool>) -> Disposer

Substitute the entry for t.name(), or append when there is none.

Distinct from register because that one appends and get returns the first name match, so re-registering an existing name leaves the original in front and the new instance unreachable.

Source

fn remove(&self, name: &str) -> usize

Withdraw every registration under name. Returns how many went.

Present so a contributor can be unloaded cleanly. Masking a tool with a deny rule leaves it in the registry, still visible to anything that enumerates it; removal is what actually takes it out.

Provided Methods§

Source

fn names(&self) -> Vec<String>

Source

fn len(&self) -> usize

Source

fn is_empty(&self) -> bool

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§