pub struct ToolSet(/* private fields */);Expand description
The non-empty, duplicate-free tools one server is restricted to.
Deserializes from a list of tool names and rejects an empty list or a repeated tool at load time.
§Examples
use mcpls_core::config::{ToolKind, ToolSet};
let set = ToolSet::new(vec![ToolKind::Hover, ToolKind::Rename]).unwrap();
assert!(set.contains(ToolKind::Hover));
assert!(ToolSet::new(vec![]).is_err());
assert!(ToolSet::new(vec![ToolKind::Hover, ToolKind::Hover]).is_err());Implementations§
Source§impl ToolSet
impl ToolSet
Sourcepub fn new(tools: Vec<ToolKind>) -> Result<Self, InvalidToolSet>
pub fn new(tools: Vec<ToolKind>) -> Result<Self, InvalidToolSet>
Builds a set from tools, preserving their order.
§Errors
Returns InvalidToolSet::Empty for an empty list and
InvalidToolSet::Duplicate for the first repeated tool.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ToolSet
impl<'de> Deserialize<'de> for ToolSet
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ToolSet
Source§impl<'a> IntoIterator for &'a ToolSet
impl<'a> IntoIterator for &'a ToolSet
impl StructuralPartialEq for ToolSet
Auto Trait Implementations§
impl Freeze for ToolSet
impl RefUnwindSafe for ToolSet
impl Send for ToolSet
impl Sync for ToolSet
impl Unpin for ToolSet
impl UnsafeUnpin for ToolSet
impl UnwindSafe 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.