this/core/store.rs
1//! Store traits for filtering and sorting
2
3use serde_json::Value;
4
5/// Trait for stores that support filtering and sorting
6///
7/// Implement this trait for stores that support generic querying with
8/// filters and sorting capabilities.
9pub trait QueryableStore<T>: Send + Sync {
10 /// Apply filters to a collection of entities
11 ///
12 /// # Parameters
13 /// - `data`: Collection of entities to filter
14 /// - `filter`: Filter criteria as JSON Value
15 ///
16 /// # Returns
17 /// Filtered collection
18 fn apply_filters(&self, data: Vec<T>, filter: &Value) -> Vec<T>;
19
20 /// Apply sorting to a collection of entities
21 ///
22 /// # Parameters
23 /// - `data`: Collection of entities to sort (will be modified)
24 /// - `sort`: Sort expression (e.g., "field:asc" or "field:desc")
25 ///
26 /// # Returns
27 /// Sorted collection
28 fn apply_sort(&self, data: Vec<T>, sort: &str) -> Vec<T>;
29
30 /// Get all entities (unfiltered, unsorted)
31 fn list_all(&self) -> Vec<T>;
32}