| Crates.io | queriable_storage |
| lib.rs | queriable_storage |
| version | 0.3.0 |
| created_at | 2020-10-10 21:52:36.929459+00 |
| updated_at | 2020-10-13 19:22:12.47012+00 |
| description | queriable_storage is a create that provides the QueriableDataStore that can be queried by multiple filters. |
| homepage | |
| repository | https://github.com/Kaladum/queriable_storage |
| max_upload_size | |
| id | 298184 |
| size | 49,727 |
Queriable storage implementation in Rust
This crate provides the QueriableDataStore struct that can be queried by multiple filters.
use queriable_storage::QueriableDataStore;
struct Person {
first_name: &'static str,
last_name: &'static str,
age: u32,
}
let persons:Vec<Person> = vec![/* ...*/];
let storage: QueriableDataStore<Person> = persons.into();
let first_name_index = storage.get_index(|v| v.first_name);
let last_name_index = storage.get_index(|v| v.last_name);
let age_index = storage.get_index(|v| v.age);
let filtered: Vec<&Person> = storage
.filter(
(first_name_index.filter_eq("Isaiah") & last_name_index.filter_eq("Mccarthy"))
| (age_index.filter_lt(30) | age_index.filter_gte(60)),
)
.collect();