pub struct ToolPrefix(/* private fields */);Expand description
A validated McpConfig::tool_prefix value.
Every mcpls tool name gains a {prefix}_ prefix when this is configured,
so an MCP client can tell apart tools exposed by multiple concurrently
running mcpls bridges. A value must be non-empty, at most
MAX_MCP_TOOL_PREFIX_BYTES bytes, contain only ASCII letters, digits,
_, and -, and both start and end with an ASCII letter or digit –
this last rule rejects (rather than silently strips) a trailing
separator, so "optics" and "optics_" cannot become two spellings of
the same configuration. The validator runs once, at construction, making
an invalid prefix unrepresentable: there is no way to observe a
ToolPrefix whose value doesn’t already satisfy these rules.
This differs from title/description/instructions, whose invalid
values surface as Error::InvalidConfig from ServerConfig::validate
– called explicitly, after loading. A malformed prefix is not merely
cosmetic (it would put an invalid tool name on the wire, an MCP protocol
violation), and McplsServer::new
is pub and infallible, so this type validates eagerly during
deserialization instead and surfaces failures as Error::TomlDe, which
additionally carries the offending line from the TOML source.
§Examples
use mcpls_core::config::ToolPrefix;
let prefix: ToolPrefix = "optics".parse().unwrap();
assert_eq!(prefix.as_str(), "optics");
assert!("optics_".parse::<ToolPrefix>().is_err());Implementations§
Trait Implementations§
Source§impl Clone for ToolPrefix
impl Clone for ToolPrefix
Source§fn clone(&self) -> ToolPrefix
fn clone(&self) -> ToolPrefix
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ToolPrefix
impl Debug for ToolPrefix
Source§impl<'de> Deserialize<'de> for ToolPrefix
impl<'de> Deserialize<'de> for ToolPrefix
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>,
Source§impl Display for ToolPrefix
impl Display for ToolPrefix
impl Eq for ToolPrefix
Source§impl FromStr for ToolPrefix
impl FromStr for ToolPrefix
Source§impl PartialEq for ToolPrefix
impl PartialEq for ToolPrefix
Source§impl Serialize for ToolPrefix
impl Serialize for ToolPrefix
impl StructuralPartialEq for ToolPrefix
Auto Trait Implementations§
impl Freeze for ToolPrefix
impl RefUnwindSafe for ToolPrefix
impl Send for ToolPrefix
impl Sync for ToolPrefix
impl Unpin for ToolPrefix
impl UnsafeUnpin for ToolPrefix
impl UnwindSafe for ToolPrefix
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
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
key and return true if they are equal.