[−][src]Struct codd::Database
Stores data in relation instances and implements incremental view maintenance over them.
Example:
use codd::{Database, expression::Select}; // create a new database: let mut db = Database::new(); // add a new relation "numbers" with tuples of type `u32` to `db`: let numbers = db.add_relation::<u32>("numbers").unwrap(); // create a view for odd numbers in `numbers`: let odds = db.store_view(Select::new(numbers.clone(), |i| i % 2 == 1)).unwrap(); // insert some items in `numbers`: db.insert(&numbers, vec![4, 8, 15, 16, 23, 42].into()).unwrap(); // query `db` for `numbers` and `odds`: let numbers_data = db.evaluate(&numbers).unwrap(); let odds_data = db.evaluate(&odds).unwrap(); assert_eq!(vec![4, 8, 15, 16, 23, 42], numbers_data.into_tuples()); assert_eq!(vec![15, 23], odds_data.into_tuples()); // go nuts: db.insert(&numbers, vec![8, 888, 23, 1001, 8008, 101].into()).unwrap(); // query `db` again: let numbers_data = db.evaluate(&numbers).unwrap(); let odds_data = db.evaluate(&odds).unwrap(); assert_eq!(vec![4, 8, 15, 16, 23, 42, 101, 888, 1001, 8008], numbers_data.into_tuples()); assert_eq!(vec![15, 23, 101, 1001], odds_data.into_tuples());
Implementations
impl Database
[src]
pub fn new() -> Self
[src]
Creates a new empty database.
pub fn evaluate<T, E>(&self, expression: &E) -> Result<Tuples<T>, Error> where
T: Tuple,
E: ExpressionExt<T>,
[src]
T: Tuple,
E: ExpressionExt<T>,
Evaluates expression
in the database and returns the result in a Tuples
object.
pub fn add_relation<T>(&mut self, name: &str) -> Result<Relation<T>, Error> where
T: Tuple + 'static,
[src]
T: Tuple + 'static,
Adds a new relation instance identified by name
to the database and returns a
Relation
object that can be used to access the instance.
pub fn insert<T>(
&self,
relation: &Relation<T>,
tuples: Tuples<T>
) -> Result<(), Error> where
T: Tuple + 'static,
[src]
&self,
relation: &Relation<T>,
tuples: Tuples<T>
) -> Result<(), Error> where
T: Tuple + 'static,
Inserts tuples in the Instance
corresponding to relation
.
pub fn store_view<T, E, I>(
&mut self,
expression: I
) -> Result<View<T, E>, Error> where
T: Tuple + 'static,
E: ExpressionExt<T> + 'static,
I: IntoExpression<T, E>,
[src]
&mut self,
expression: I
) -> Result<View<T, E>, Error> where
T: Tuple + 'static,
E: ExpressionExt<T> + 'static,
I: IntoExpression<T, E>,
Stores a new view over expression
and returns a View
objeect that can be
evaluated as a view.
Trait Implementations
impl Clone for Database
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Default for Database
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Database
impl !Send for Database
impl !Sync for Database
impl Unpin for Database
impl !UnwindSafe for Database
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,