pub struct QueryStore { /* private fields */ }Expand description
In-memory storage for named queries.
Provides CRUD operations for managing named JMESPath queries within a session. Queries are stored by name and can be listed alphabetically.
§Example
use jpx_engine::{QueryStore, StoredQuery};
let mut store = QueryStore::new();
// Add some queries
store.define(StoredQuery {
name: "first".to_string(),
expression: "@[0]".to_string(),
description: None,
});
store.define(StoredQuery {
name: "last".to_string(),
expression: "@[-1]".to_string(),
description: None,
});
// List them (alphabetically sorted)
let queries = store.list();
assert_eq!(queries[0].name, "first");
assert_eq!(queries[1].name, "last");
// Delete one
store.delete("first");
assert_eq!(store.len(), 1);Implementations§
Source§impl QueryStore
impl QueryStore
Sourcepub fn define(&mut self, query: StoredQuery) -> Option<StoredQuery>
pub fn define(&mut self, query: StoredQuery) -> Option<StoredQuery>
Stores a named query.
If a query with the same name already exists, it is replaced and the old query is returned.
§Returns
Some(StoredQuery) if a query was replaced, None if this is a new name.
Sourcepub fn get(&self, name: &str) -> Option<&StoredQuery>
pub fn get(&self, name: &str) -> Option<&StoredQuery>
Sourcepub fn delete(&mut self, name: &str) -> Option<StoredQuery>
pub fn delete(&mut self, name: &str) -> Option<StoredQuery>
Removes a query by name.
§Returns
Some(StoredQuery) containing the removed query, None if not found.
Sourcepub fn list(&self) -> Vec<&StoredQuery>
pub fn list(&self) -> Vec<&StoredQuery>
Lists all stored queries, sorted alphabetically by name.
Trait Implementations§
Source§impl Debug for QueryStore
impl Debug for QueryStore
Source§impl Default for QueryStore
impl Default for QueryStore
Source§fn default() -> QueryStore
fn default() -> QueryStore
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for QueryStore
impl RefUnwindSafe for QueryStore
impl Send for QueryStore
impl Sync for QueryStore
impl Unpin for QueryStore
impl UnwindSafe for QueryStore
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more