pub struct MetadataCache { /* private fields */ }Expand description
Stable since 0.63.0
In-memory + on-disk metadata cache.Implementations§
Source§impl MetadataCache
impl MetadataCache
Sourcepub fn new() -> MetadataCache
pub fn new() -> MetadataCache
Create a new cache, resolving the default path under
dirs::config_dir()/oxicode/mcp-cache.json.
Sourcepub fn with_path(cache_path: PathBuf) -> MetadataCache
pub fn with_path(cache_path: PathBuf) -> MetadataCache
Create a cache rooted at a specific file path (used by tests).
Sourcepub fn load(&self) -> Result<(), Error>
pub fn load(&self) -> Result<(), Error>
Load the cache from disk. Missing file is not an error.
Sourcepub fn get_tools(
&self,
server_name: &str,
prefix_mode: &ToolPrefix,
) -> Vec<ToolMetadata>
pub fn get_tools( &self, server_name: &str, prefix_mode: &ToolPrefix, ) -> Vec<ToolMetadata>
Return the cached tools for a server, converted to ToolMetadata
using the supplied prefix_mode for the display name.
Returns an empty Vec if the server has no cached tools.
Sourcepub fn update(
&self,
server_name: &str,
tools: &[McpToolDef],
) -> Result<(), Error>
pub fn update( &self, server_name: &str, tools: &[McpToolDef], ) -> Result<(), Error>
Update the cached tools for a server and atomically persist to disk.
Sourcepub fn invalidate(&self, server_name: &str) -> Result<(), Error>
pub fn invalidate(&self, server_name: &str) -> Result<(), Error>
Remove a server’s cached tools and persist.
Sourcepub fn cached_servers(&self) -> Vec<String>
pub fn cached_servers(&self) -> Vec<String>
All server names that have cached tools.
Trait Implementations§
Source§impl Default for MetadataCache
impl Default for MetadataCache
Source§fn default() -> MetadataCache
fn default() -> MetadataCache
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for MetadataCache
impl !RefUnwindSafe for MetadataCache
impl Send for MetadataCache
impl Sync for MetadataCache
impl Unpin for MetadataCache
impl UnsafeUnpin for MetadataCache
impl UnwindSafe for MetadataCache
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