llamadb/src/databasestorage.rs
2015-04-13 07:45:04 -06:00

24 lines
686 B
Rust

use databaseinfo::DatabaseInfo;
use std::borrow::Cow;
use std::cmp::Eq;
use std::hash::Hash;
pub trait DatabaseStorage {
type Info: DatabaseInfo;
fn scan_table<'a>(&'a self, table: &'a <Self::Info as DatabaseInfo>::Table)
-> Box<Group<ColumnValue=<Self::Info as DatabaseInfo>::ColumnValue> + 'a>;
}
pub trait Group {
type ColumnValue: Sized + Clone + Eq + Hash + 'static;
/// Returns any arbitrary row in the group.
/// Returns None if the group contains no rows.
fn get_any_row<'a>(&'a self) -> Option<Cow<'a, [Self::ColumnValue]>>;
fn count(&self) -> u64;
fn iter<'a>(&'a self) -> Box<Iterator<Item=Cow<'a, [Self::ColumnValue]>> + 'a>;
}