Skip to main content

SavedQueryStore

Trait SavedQueryStore 

Source
pub trait SavedQueryStore: Send + Sync {
    // Required methods
    fn save(
        &self,
        engine: Option<&Engine>,
        query: SavedQuery,
    ) -> Result<(), McpError>;
    fn get(
        &self,
        engine: Option<&Engine>,
        name: &str,
    ) -> Result<Option<SavedQuery>, McpError>;
    fn list(&self, engine: Option<&Engine>) -> Result<Vec<SavedQuery>, McpError>;
    fn delete(
        &self,
        engine: Option<&Engine>,
        name: &str,
    ) -> Result<bool, McpError>;
}
Expand description

CRUD interface shared by both storage backends.

All methods take &self because both variants use interior mutability (Mutex<HashMap> or Hyper’s own connection locking), so a single Arc<dyn SavedQueryStore> can be shared across the tool router and resource handler without further wrapping.

engine is passed in by the caller when the operation needs to touch Hyper; stores that don’t need it (e.g. SessionStore) simply ignore the argument.

Required Methods§

Source

fn save( &self, engine: Option<&Engine>, query: SavedQuery, ) -> Result<(), McpError>

Persist a new query. Returns an AlreadyExists-class error (currently SchemaMismatch, with a clear message) if name is already in use — callers should delete first if overwriting is intended.

§Errors
Source

fn get( &self, engine: Option<&Engine>, name: &str, ) -> Result<Option<SavedQuery>, McpError>

Retrieve a single saved query by name, or Ok(None) if not found.

§Errors

Returns ErrorCode::InternalError for store-specific failures (poisoned mutex, catalog read failure, JSON decode failure of a persisted row).

Source

fn list(&self, engine: Option<&Engine>) -> Result<Vec<SavedQuery>, McpError>

List all saved queries in alphabetical-by-name order. Empty workspaces return Ok(vec![]), never an error.

§Errors

Returns ErrorCode::InternalError for store-specific failures (poisoned mutex, catalog read failure, JSON decode failure).

Source

fn delete(&self, engine: Option<&Engine>, name: &str) -> Result<bool, McpError>

Remove a saved query by name. Returns Ok(false) if the name wasn’t present, Ok(true) if it was removed.

§Errors

Returns ErrorCode::InternalError for store-specific failures (poisoned mutex, Hyper delete statement failure).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§