pub struct LayeredToolRegistry { /* private fields */ }Expand description
A registry that layers one set of tools over another.
Exists to answer a question a single implementation cannot: is
ToolRegistry actually a contract, or just the shape of
InMemoryToolRegistry? Writing a second implementation is what finds the
methods that leaked an assumption about the first — and this one does not
store Vec<Entry> at all, so anything that only worked because the backing
store was a vector shows up here.
Reads consult the overlay first, then the base, so an overlay entry shadows a base entry of the same name. Writes only ever touch the overlay: the base is borrowed, and silently mutating something you were handed is how a “layer” becomes a leak.
Implementations§
Trait Implementations§
Source§impl ToolRegistry for LayeredToolRegistry
impl ToolRegistry for LayeredToolRegistry
Source§fn register(&self, t: Arc<dyn Tool>) -> Disposer
fn register(&self, t: Arc<dyn Tool>) -> Disposer
Registering a name the layer hid makes the new entry visible; the base entry stays hidden behind it.
Source§fn remove(&self, name: &str) -> usize
fn remove(&self, name: &str) -> usize
Removes from the overlay, then hides whatever the base still exposes.
“Removed” has to mean “not visible through this registry” — leaving a
base entry reachable after a remove would be the exact leak this
layer exists to avoid.
fn list(&self) -> Vec<Arc<dyn Tool>>
fn get(&self, n: &str) -> Option<Arc<dyn Tool>>
Source§fn replace(&self, t: Arc<dyn Tool>) -> Disposer
fn replace(&self, t: Arc<dyn Tool>) -> Disposer
t.name(), or append when there is none. Read more