Return references by default

Also drop dependency on Table.
This commit is contained in:
2019-10-30 15:33:24 +01:00
parent 1231f42728
commit 36997ae5a3

View File

@@ -1,5 +1,3 @@
use ironsea_table::Table;
pub trait Record<K> {
fn key(&self) -> K; // Extract key from record.
}
@@ -8,18 +6,15 @@ pub trait RecordFields<F> {
fn fields(&self) -> F;
}
pub trait RecordBuild<K, F, R> {
fn build(key: &K, fields: &F) -> R;
}
pub trait Indexed<T: Table<R>, R: Record<K>, K> {
// Generic types are not sorted alphabetically, to match next trait semantic order
pub trait Indexed<R, K> {
fn find(&self, key: &K) -> Vec<&R>;
fn find_range(&self, start: &K, end: &K) -> Vec<&R>;
}
pub trait IndexedOwned<T: Table<R>, R: Record<K>, K> {
fn find(&self, key: &K) -> Vec<R>;
pub trait IndexedDestructured<F, K> {
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)>;
}