pub struct ResourcePattern { /* private fields */ }Expand description
A pattern that matches resources.
Supports exact matches and glob patterns (*, **, ?).
Implementations§
Source§impl ResourcePattern
impl ResourcePattern
Sourcepub fn new(pattern: impl Into<String>) -> CapabilityResult<Self>
pub fn new(pattern: impl Into<String>) -> CapabilityResult<Self>
Create a new resource pattern.
§Errors
Returns CapabilityError::InvalidPattern if the glob pattern is invalid
or contains path traversal sequences (..).
Sourcepub fn exact(pattern: impl Into<String>) -> CapabilityResult<Self>
pub fn exact(pattern: impl Into<String>) -> CapabilityResult<Self>
Create an exact match pattern.
§Errors
Returns CapabilityError::InvalidPattern if the pattern contains
path traversal sequences (..).
Sourcepub fn file_dir(path: impl Into<String>) -> CapabilityResult<Self>
pub fn file_dir(path: impl Into<String>) -> CapabilityResult<Self>
Create a pattern matching a file directory and all contents beneath it.
Example: file_dir("/home/user") matches file:///home/user/any/nested/file.
§Errors
Returns CapabilityError::InvalidPattern if the path contains path traversal.
Sourcepub fn file_exact(path: impl Into<String>) -> CapabilityResult<Self>
pub fn file_exact(path: impl Into<String>) -> CapabilityResult<Self>
Create a pattern matching an exact file path.
Example: file_exact("/home/user/file.txt") matches only file:///home/user/file.txt.
§Errors
Returns CapabilityError::InvalidPattern if the path contains path traversal.
Sourcepub fn mcp_tool(
server: impl Into<String>,
tool: impl Into<String>,
) -> CapabilityResult<Self>
pub fn mcp_tool( server: impl Into<String>, tool: impl Into<String>, ) -> CapabilityResult<Self>
Create a pattern matching a specific MCP tool on a specific server.
Example: mcp_tool("filesystem", "read_file") matches mcp://filesystem:read_file.
§Errors
Returns CapabilityError::InvalidPattern if server or tool names
contain path traversal sequences.
Sourcepub fn mcp_server(server: impl Into<String>) -> CapabilityResult<Self>
pub fn mcp_server(server: impl Into<String>) -> CapabilityResult<Self>
Create a pattern matching all tools on an MCP server.
Example: mcp_server("filesystem") matches mcp://filesystem:read_file,
mcp://filesystem:write_file, etc.
§Errors
Returns CapabilityError::InvalidPattern if the glob compilation fails.
Trait Implementations§
Source§impl Clone for ResourcePattern
impl Clone for ResourcePattern
Source§fn clone(&self) -> ResourcePattern
fn clone(&self) -> ResourcePattern
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResourcePattern
impl Debug for ResourcePattern
Source§impl<'de> Deserialize<'de> for ResourcePattern
impl<'de> Deserialize<'de> for ResourcePattern
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 ResourcePattern
impl Display for ResourcePattern
Source§impl Hash for ResourcePattern
impl Hash for ResourcePattern
Source§impl PartialEq for ResourcePattern
impl PartialEq for ResourcePattern
Source§impl Serialize for ResourcePattern
impl Serialize for ResourcePattern
impl Eq for ResourcePattern
Auto Trait Implementations§
impl Freeze for ResourcePattern
impl RefUnwindSafe for ResourcePattern
impl Send for ResourcePattern
impl Sync for ResourcePattern
impl Unpin for ResourcePattern
impl UnsafeUnpin for ResourcePattern
impl UnwindSafe for ResourcePattern
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,
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.