[][src]Struct codd::expression::Join

pub struct Join<K, L, R, Left, Right, T> where
    K: Tuple,
    L: Tuple,
    R: Tuple,
    T: Tuple,
    Left: Expression<L>,
    Right: Expression<R>, 
{ /* fields omitted */ }

Represents the join of its left and right sub-expressions.

Example:

use codd::{Database, expression::Join};

let mut db = Database::new();
let fruit = db.add_relation::<(i32, String)>("R").unwrap();
let numbers = db.add_relation::<i32>("S").unwrap();

db.insert(&fruit, vec![
   (0, "Apple".to_string()),
   (1, "Banana".to_string()),
   (2, "Cherry".to_string())
].into());
db.insert(&numbers, vec![0, 2].into());

let join = Join::new(
    &fruit,
    &numbers,
    |t| t.0,  // first element of tuples in `r` is the key for join
    |&t| t,   // the values in `s` are keys for join
    // make resulting values from key `k`, left value `l` and right value `r`:
    |k, l, r| format!("{}{}", l.1, k + r)
);

assert_eq!(vec!["Apple0", "Cherry4"], db.evaluate(&join).unwrap().into_tuples());

Implementations

impl<K, L, R, Left, Right, T> Join<K, L, R, Left, Right, T> where
    K: Tuple,
    L: Tuple,
    R: Tuple,
    T: Tuple,
    Left: Expression<L>,
    Right: Expression<R>, 
[src]

pub fn new<IL, IR>(
    left: IL,
    right: IR,
    left_key: impl FnMut(&L) -> K + 'static,
    right_key: impl FnMut(&R) -> K + 'static,
    mapper: impl FnMut(&K, &L, &R) -> T + 'static
) -> Self where
    IL: IntoExpression<L, Left>,
    IR: IntoExpression<R, Right>, 
[src]

Creates a new Join expression over left and right where left_key and right_key are closures that return the join key for tuples of left and right respectively. The closure mapper computes the tuples of the resulting expression from the join key and the tuples of left and right.

pub fn left(&self) -> &Left[src]

Returns a reference to the left sub-expression.

pub fn right(&self) -> &Right[src]

Returns a reference to the right sub-expression.

Trait Implementations

impl<K: Clone, L: Clone, R: Clone, Left: Clone, Right: Clone, T: Clone> Clone for Join<K, L, R, Left, Right, T> where
    K: Tuple,
    L: Tuple,
    R: Tuple,
    T: Tuple,
    Left: Expression<L>,
    Right: Expression<R>, 
[src]

impl<K, L, R, Left, Right, T> Debug for Join<K, L, R, Left, Right, T> where
    K: Tuple,
    L: Tuple,
    R: Tuple,
    T: Tuple,
    Left: Expression<L>,
    Right: Expression<R>, 
[src]

impl<K, L, R, Left, Right, T> Expression<T> for Join<K, L, R, Left, Right, T> where
    K: Tuple,
    L: Tuple,
    R: Tuple,
    T: Tuple,
    Left: Expression<L>,
    Right: Expression<R>, 
[src]

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

Auto Trait Implementations

impl<K, L, R, Left, Right, T> !RefUnwindSafe for Join<K, L, R, Left, Right, T>

impl<K, L, R, Left, Right, T> !Send for Join<K, L, R, Left, Right, T>

impl<K, L, R, Left, Right, T> !Sync for Join<K, L, R, Left, Right, T>

impl<K, L, R, Left, Right, T> Unpin for Join<K, L, R, Left, Right, T> where
    Left: Unpin,
    Right: Unpin

impl<K, L, R, Left, Right, T> !UnwindSafe for Join<K, L, R, Left, Right, T>

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.