[][src]Struct codd::expression::View

pub struct View<T, E> where
    T: Tuple,
    E: Expression<T>, 
{ /* fields omitted */ }

Represents a view in the database.

Example:

use codd::{Database, expression::{Product, View}};

let mut db = Database::new();
let dividends = db.add_relation("dividends").unwrap();
let divisors = db.add_relation("divisors").unwrap();

db.insert(&dividends, vec![6, 12, 18].into()).unwrap();
db.insert(&divisors, vec![2, 3].into()).unwrap();

// divide all elements of `dividends` by all elements of `divisors`:
let quotients = Product::new(
    dividends.clone(),
    divisors.clone(),
    |&l, &r| l/r
);
let view = db.store_view(quotients.clone()).unwrap();

// `view` and `quotients` evaluate to the same result:
assert_eq!(vec![2, 3, 4, 6, 9], db.evaluate(&quotients).unwrap().into_tuples());
assert_eq!(vec![2, 3, 4, 6, 9], db.evaluate(&view).unwrap().into_tuples());

db.insert(&dividends, vec![24, 30].into());
db.insert(&divisors, vec![1].into());

// the view gets updated automatically:
assert_eq!(
   vec![2, 3, 4, 6, 8, 9, 10, 12, 15, 18, 24, 30],
   db.evaluate(&view).unwrap().into_tuples()
);

use codd::expression::Difference;
// incremental view update for `Difference` is currently not supported:
assert!(db.store_view(Difference::new(dividends, divisors)).is_err());

Trait Implementations

impl<T: Clone, E: Clone> Clone for View<T, E> where
    T: Tuple,
    E: Expression<T>, 
[src]

impl<T: Debug, E: Debug> Debug for View<T, E> where
    T: Tuple,
    E: Expression<T>, 
[src]

impl<T: Eq, E: Eq> Eq for View<T, E> where
    T: Tuple,
    E: Expression<T>, 
[src]

impl<T, E> Expression<T> for View<T, E> where
    T: Tuple + 'static,
    E: Expression<T> + 'static, 
[src]

impl<T: Tuple> From<View<T, Mono<T>>> for Mono<T>[src]

impl<T: PartialEq, E: PartialEq> PartialEq<View<T, E>> for View<T, E> where
    T: Tuple,
    E: Expression<T>, 
[src]

impl<T, E> StructuralEq for View<T, E> where
    T: Tuple,
    E: Expression<T>, 
[src]

impl<T, E> StructuralPartialEq for View<T, E> where
    T: Tuple,
    E: Expression<T>, 
[src]

Auto Trait Implementations

impl<T, E> RefUnwindSafe for View<T, E> where
    E: RefUnwindSafe,
    T: RefUnwindSafe

impl<T, E> Send for View<T, E> where
    E: Send,
    T: Send

impl<T, E> Sync for View<T, E> where
    E: Sync,
    T: Sync

impl<T, E> Unpin for View<T, E> where
    E: Unpin,
    T: Unpin

impl<T, E> UnwindSafe for View<T, E> where
    E: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, E> IntoExpression<T, E> for E where
    E: Expression<T>,
    T: Tuple
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.