LockJoinQuery

Struct LockJoinQuery 

Source
pub struct LockJoinQuery<'a, L, R, LL, LR>
where LL: LockValue<L> + 'a, LR: LockValue<R> + 'a,
{ /* private fields */ }
Expand description

A join query builder for locked data structures.

Enables joining two collections of locked values.

Implementations§

Source§

impl<'a, L, R, LL, LR> LockJoinQuery<'a, L, R, LL, LR>
where L: 'static, R: 'static, LL: LockValue<L> + 'a, LR: LockValue<R> + 'a,

Source

pub fn new( left: Vec<&'a LL>, right: Vec<&'a LR>, ) -> LockJoinQuery<'a, L, R, LL, LR>

Create a new join query from two collections of locks.

Source

pub fn inner_join<LK, RK, M, Out>( &self, left_key: KeyPaths<L, LK>, right_key: KeyPaths<R, RK>, mapper: M, ) -> Vec<Out>
where LK: Eq + Clone + 'static + PartialEq<RK>, RK: Eq + Clone + 'static, M: Fn(&L, &R) -> Out, L: Clone, R: Clone,

Perform an INNER JOIN.

Returns only pairs where keys match.

§Example
let results = LockJoinQuery::new(&users, &orders)
    .inner_join(
        User::id(),
        Order::user_id(),
        |user, order| (user.name.clone(), order.total)
    );
Source

pub fn left_join<LK, RK, M, Out>( &self, left_key: KeyPaths<L, LK>, right_key: KeyPaths<R, RK>, mapper: M, ) -> Vec<Out>
where LK: Eq + Clone + 'static + PartialEq<RK>, RK: Eq + Clone + 'static, M: Fn(&L, Option<&R>) -> Out, L: Clone, R: Clone,

Perform a LEFT JOIN.

Returns all left items with optional right matches.

§Example
let results = LockJoinQuery::new(&users, &orders)
    .left_join(
        User::id(),
        Order::user_id(),
        |user, order_opt| match order_opt {
            Some(order) => format!("{} has order {}", user.name, order.id),
            None => format!("{} has no orders", user.name),
        }
    );
Source

pub fn right_join<LK, RK, M, Out>( &self, left_key: KeyPaths<L, LK>, right_key: KeyPaths<R, RK>, mapper: M, ) -> Vec<Out>
where LK: Eq + Clone + 'static + PartialEq<RK>, RK: Eq + Clone + 'static, M: Fn(Option<&L>, &R) -> Out, L: Clone, R: Clone,

Perform a RIGHT JOIN.

Returns all right items with optional left matches.

Source

pub fn cross_join<M, Out>(&self, mapper: M) -> Vec<Out>
where M: Fn(&L, &R) -> Out, L: Clone, R: Clone,

Perform a CROSS JOIN (Cartesian product).

Returns all combinations of left and right items.

Auto Trait Implementations§

§

impl<'a, L, R, LL, LR> Freeze for LockJoinQuery<'a, L, R, LL, LR>

§

impl<'a, L, R, LL, LR> RefUnwindSafe for LockJoinQuery<'a, L, R, LL, LR>

§

impl<'a, L, R, LL, LR> Send for LockJoinQuery<'a, L, R, LL, LR>
where L: Send, R: Send, LL: Sync, LR: Sync,

§

impl<'a, L, R, LL, LR> Sync for LockJoinQuery<'a, L, R, LL, LR>
where L: Sync, R: Sync, LL: Sync, LR: Sync,

§

impl<'a, L, R, LL, LR> Unpin for LockJoinQuery<'a, L, R, LL, LR>
where L: Unpin, R: Unpin,

§

impl<'a, L, R, LL, LR> UnwindSafe for LockJoinQuery<'a, L, R, LL, LR>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.