Return references by default
Also drop dependency on Table.
This commit is contained in:
15
src/lib.rs
15
src/lib.rs
@@ -1,5 +1,3 @@
|
|||||||
use ironsea_table::Table;
|
|
||||||
|
|
||||||
pub trait Record<K> {
|
pub trait Record<K> {
|
||||||
fn key(&self) -> K; // Extract key from record.
|
fn key(&self) -> K; // Extract key from record.
|
||||||
}
|
}
|
||||||
@@ -8,18 +6,15 @@ pub trait RecordFields<F> {
|
|||||||
fn fields(&self) -> F;
|
fn fields(&self) -> F;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait RecordBuild<K, F, R> {
|
// Generic types are not sorted alphabetically, to match next trait semantic order
|
||||||
fn build(key: &K, fields: &F) -> R;
|
pub trait Indexed<R, K> {
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Indexed<T: Table<R>, R: Record<K>, K> {
|
|
||||||
fn find(&self, key: &K) -> Vec<&R>;
|
fn find(&self, key: &K) -> Vec<&R>;
|
||||||
|
|
||||||
fn find_range(&self, start: &K, end: &K) -> Vec<&R>;
|
fn find_range(&self, start: &K, end: &K) -> Vec<&R>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait IndexedOwned<T: Table<R>, R: Record<K>, K> {
|
pub trait IndexedDestructured<F, K> {
|
||||||
fn find(&self, key: &K) -> Vec<R>;
|
fn find(&self, key: &K) -> Vec<&F>;
|
||||||
|
|
||||||
fn find_range(&self, start: &K, end: &K) -> Vec<R>;
|
fn find_range(&self, start: &K, end: &K) -> Vec<(K, &F)>;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user