pub struct ToolSet { /* private fields */ }Expand description
Named tools available to a call. Insertion order is preserved; names are unique.
Implementations§
Source§impl ToolSet
impl ToolSet
Sourcepub fn insert(
self,
name: impl Into<ToolName>,
tool: Tool,
) -> Result<Self, DuplicateToolError>
pub fn insert( self, name: impl Into<ToolName>, tool: Tool, ) -> Result<Self, DuplicateToolError>
Adds a tool, consuming and returning the set.
§Errors
Returns DuplicateToolError when name is already present.
Sourcepub fn try_insert(
&mut self,
name: impl Into<ToolName>,
tool: Tool,
) -> Result<(), DuplicateToolError>
pub fn try_insert( &mut self, name: impl Into<ToolName>, tool: Tool, ) -> Result<(), DuplicateToolError>
Sourcepub fn try_insert_arc(
&mut self,
name: impl Into<ToolName>,
tool: Arc<Tool>,
) -> Result<(), DuplicateToolError>
pub fn try_insert_arc( &mut self, name: impl Into<ToolName>, tool: Arc<Tool>, ) -> Result<(), DuplicateToolError>
Sourcepub fn replace(
&mut self,
name: impl Into<ToolName>,
tool: Arc<Tool>,
) -> Option<Arc<Tool>>
pub fn replace( &mut self, name: impl Into<ToolName>, tool: Arc<Tool>, ) -> Option<Arc<Tool>>
Inserts or replaces a tool, keeping its position when replacing.
Sourcepub fn remove(&mut self, name: &str) -> Option<Arc<Tool>>
pub fn remove(&mut self, name: &str) -> Option<Arc<Tool>>
Removes a tool, preserving the order of the others.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&ToolName, &Arc<Tool>)> + '_
pub fn iter(&self) -> impl Iterator<Item = (&ToolName, &Arc<Tool>)> + '_
Tools in insertion order.
Sourcepub fn filter_active(&self, active: &[ToolName]) -> Self
pub fn filter_active(&self, active: &[ToolName]) -> Self
Keeps only the named tools (order of this set). Unknown names are ignored.
Sourcepub fn merge(self, other: Self) -> Result<Self, DuplicateToolError>
pub fn merge(self, other: Self) -> Result<Self, DuplicateToolError>
Merges another set into this one.
§Errors
Returns DuplicateToolError for the first name present in both.
Trait Implementations§
Source§impl<'a> IntoIterator for &'a ToolSet
impl<'a> IntoIterator for &'a ToolSet
Auto Trait Implementations§
impl !RefUnwindSafe for ToolSet
impl !UnwindSafe for ToolSet
impl Freeze for ToolSet
impl Send for ToolSet
impl Sync for ToolSet
impl Unpin for ToolSet
impl UnsafeUnpin for ToolSet
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