pub struct JoinQuery<'a, L, R>where
    L: 'static,
    R: 'static,{ /* private fields */ }Expand description
A query builder for joining two collections.
Supports inner joins, left joins, and filtered joins using key-paths for type-safe join conditions.
§Type Parameters
'a- The lifetime of the data being joinedL- The type of items in the left collectionR- The type of items in the right collection
§Example
let user_orders = JoinQuery::new(&users, &orders)
    .inner_join(
        User::id(),
        Order::user_id(),
        |user, order| (user.name.clone(), order.total)
    );Implementations§
Source§impl<'a, L, R> JoinQuery<'a, L, R>where
    L: 'static,
    R: 'static,
 
impl<'a, L, R> JoinQuery<'a, L, R>where
    L: 'static,
    R: 'static,
Sourcepub fn inner_join<K, O, F>(
    &self,
    left_key: KeyPaths<L, K>,
    right_key: KeyPaths<R, K>,
    mapper: F,
) -> Vec<O>
 
pub fn inner_join<K, O, F>( &self, left_key: KeyPaths<L, K>, right_key: KeyPaths<R, K>, mapper: F, ) -> Vec<O>
Performs an inner join between two collections.
Returns only the pairs where the join keys match. Uses a hash-based algorithm for O(n + m) performance.
§Arguments
left_key- Key-path to the join field in the left collectionright_key- Key-path to the join field in the right collectionmapper- Function to transform matching pairs into the result type
§Example
let results = JoinQuery::new(&users, &orders)
    .inner_join(
        User::id(),
        Order::user_id(),
        |user, order| UserOrder {
            user_name: user.name.clone(),
            order_total: order.total,
        }
    );Sourcepub fn left_join<K, O, F>(
    &self,
    left_key: KeyPaths<L, K>,
    right_key: KeyPaths<R, K>,
    mapper: F,
) -> Vec<O>
 
pub fn left_join<K, O, F>( &self, left_key: KeyPaths<L, K>, right_key: KeyPaths<R, K>, mapper: F, ) -> Vec<O>
Performs a left join between two collections.
Returns all items from the left collection with optional matching items
from the right collection. If no match is found, the right item is None.
§Arguments
left_key- Key-path to the join field in the left collectionright_key- Key-path to the join field in the right collectionmapper- Function to transform pairs into the result type (right item may be None)
§Example
let results = JoinQuery::new(&users, &orders)
    .left_join(
        User::id(),
        Order::user_id(),
        |user, order| match order {
            Some(o) => format!("{} has order {}", user.name, o.id),
            None => format!("{} has no orders", user.name),
        }
    );Sourcepub fn inner_join_where<K, O, F, P>(
    &self,
    left_key: KeyPaths<L, K>,
    right_key: KeyPaths<R, K>,
    predicate: P,
    mapper: F,
) -> Vec<O>
 
pub fn inner_join_where<K, O, F, P>( &self, left_key: KeyPaths<L, K>, right_key: KeyPaths<R, K>, predicate: P, mapper: F, ) -> Vec<O>
Performs an inner join with an additional filter predicate.
Like inner_join, but only includes pairs that satisfy both the join
condition and the additional predicate.
§Arguments
left_key- Key-path to the join field in the left collectionright_key- Key-path to the join field in the right collectionpredicate- Additional condition that must be true for pairs to be includedmapper- Function to transform matching pairs into the result type
§Example
// Join orders with products, but only high-value orders
let results = JoinQuery::new(&orders, &products)
    .inner_join_where(
        Order::product_id(),
        Product::id(),
        |order, _product| order.total > 100.0,
        |order, product| (product.name.clone(), order.total)
    );Sourcepub fn right_join<K, O, F>(
    &self,
    left_key: KeyPaths<L, K>,
    right_key: KeyPaths<R, K>,
    mapper: F,
) -> Vec<O>
 
pub fn right_join<K, O, F>( &self, left_key: KeyPaths<L, K>, right_key: KeyPaths<R, K>, mapper: F, ) -> Vec<O>
Performs a right join between two collections.
Returns all items from the right collection with optional matching items
from the left collection. If no match is found, the left item is None.
§Arguments
left_key- Key-path to the join field in the left collectionright_key- Key-path to the join field in the right collectionmapper- Function to transform pairs into the result type (left item may be None)
§Example
let results = JoinQuery::new(&users, &orders)
    .right_join(
        User::id(),
        Order::user_id(),
        |user, order| match user {
            Some(u) => format!("Order {} by {}", order.id, u.name),
            None => format!("Order {} by unknown user", order.id),
        }
    );Sourcepub fn cross_join<O, F>(&self, mapper: F) -> Vec<O>
 
pub fn cross_join<O, F>(&self, mapper: F) -> Vec<O>
Performs a cross join (Cartesian product) between two collections.
Returns all possible pairs of items from both collections. Warning: This can produce very large result sets (size = left.len() * right.len()).
§Arguments
mapper- Function to transform pairs into the result type
§Example
let all_combinations = JoinQuery::new(&colors, &sizes)
    .cross_join(|color, size| ProductVariant {
        color: color.clone(),
        size: size.clone(),
    });