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§
Sourcefn save(
&self,
engine: Option<&Engine>,
query: SavedQuery,
) -> Result<(), McpError>
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
- Returns
ErrorCode::InvalidArgumentif a query with the same name already exists. - Returns
ErrorCode::InternalErrorfor store-specific failures (poisoned mutex inSessionStore, Hyper catalog errors inCatalogStore).
Sourcefn get(
&self,
engine: Option<&Engine>,
name: &str,
) -> Result<Option<SavedQuery>, McpError>
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).
Sourcefn list(&self, engine: Option<&Engine>) -> Result<Vec<SavedQuery>, McpError>
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).
Sourcefn delete(&self, engine: Option<&Engine>, name: &str) -> Result<bool, McpError>
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".