pub struct InMemoryToolRegistry { /* private fields */ }Implementations§
Source§impl InMemoryToolRegistry
impl InMemoryToolRegistry
pub fn new() -> Self
pub fn register(&self, t: Arc<dyn Tool>) -> Disposer
Sourcepub fn replace(&self, t: Arc<dyn Tool>) -> Disposer
pub fn replace(&self, t: Arc<dyn Tool>) -> Disposer
Swap the entry for t.name(), or append when there is none.
register appends unconditionally while
get returns the first name match, so re-registering an
existing name leaves the original in front and the new instance
unreachable. Use this wherever the intent is to substitute a tool that
is already present — wrapping one in a decorator, for instance.
Sourcepub fn remove(&self, name: &str) -> usize
pub fn remove(&self, name: &str) -> usize
Withdraw every registration under name; returns how many went.
pub fn get(&self, n: &str) -> Option<Arc<dyn Tool>>
pub fn list(&self) -> Vec<Arc<dyn Tool>>
pub fn names(&self) -> Vec<String>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Clone for InMemoryToolRegistry
impl Clone for InMemoryToolRegistry
Source§impl Default for InMemoryToolRegistry
impl Default for InMemoryToolRegistry
Source§impl ToolRegistry for InMemoryToolRegistry
impl ToolRegistry for InMemoryToolRegistry
fn list(&self) -> Vec<Arc<dyn Tool>>
fn get(&self, n: &str) -> Option<Arc<dyn Tool>>
Source§fn register(&self, t: Arc<dyn Tool>) -> Disposer
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
fn replace(&self, t: Arc<dyn Tool>) -> Disposer
Substitute the entry for
t.name(), or append when there is none. Read moreSource§fn remove(&self, name: &str) -> usize
fn remove(&self, name: &str) -> usize
Withdraw every registration under
name. Returns how many went. Read morefn names(&self) -> Vec<String>
fn len(&self) -> usize
fn is_empty(&self) -> bool
Auto Trait Implementations§
impl Forget for InMemoryToolRegistry
impl Freeze for InMemoryToolRegistry
impl Move for InMemoryToolRegistry
impl RefUnwindSafe for InMemoryToolRegistry
impl Send for InMemoryToolRegistry
impl Sync for InMemoryToolRegistry
impl Unpin for InMemoryToolRegistry
impl UnsafeUnpin for InMemoryToolRegistry
impl UnwindSafe for InMemoryToolRegistry
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
Mutably borrows from an owned value. Read more