Expand description
§Rust Query Builder
A powerful, type-safe query builder library for Rust that leverages key-paths for SQL-like operations on in-memory collections.
§Features
- Type-safe queries: Compile-time type checking using key-paths
 - SQL-like operations: WHERE, SELECT, ORDER BY, GROUP BY, JOIN
 - Aggregations: COUNT, SUM, AVG, MIN, MAX
 - Pagination: LIMIT and SKIP operations
 - Join operations: INNER JOIN, LEFT JOIN with custom predicates
 - Zero-cost abstractions: Leverages Rust’s zero-cost abstractions
 
§Example
use rust_queries_builder::{Query, QueryExt};
use key_paths_derive::Keypath;
#[derive(Clone, Keypath)]
struct Product {
    id: u32,
    name: String,
    price: f64,
    category: String,
}
let products = vec![
    Product { id: 1, name: "Laptop".to_string(), price: 999.99, category: "Electronics".to_string() },
    Product { id: 2, name: "Mouse".to_string(), price: 29.99, category: "Electronics".to_string() },
];
// Using extension trait - most ergonomic
let query = products.query().where_(Product::category_r(), |cat| cat == "Electronics");
let electronics = query.all();
// Traditional approach
let affordable = Query::new(&products)
    .where_(Product::price_r(), |&price| price < 100.0)
    .all();
// Lazy evaluation for better performance
let total = products.lazy_query().sum_by(Product::price_r());Modules§
- datetime
 - DateTime operations for query builder.
 - ext
 - join
 - Join query implementation for combining multiple collections.
 - lazy
 - Lazy query implementation using iterators.
 - lock_
ext  - Extended lock support for parking_lot and tokio.
 - lock_
join  - JOIN operations for locked data structures.
 - lock_
lazy  - Lazy query support for locked data structures.
 - lock_
query  - Full SQL-like query support for locked data structures.
 - lock_
view  - View-like functionality for locked data.
 - locks
 - Lock-aware querying for thread-safe data structures.
 - macros
 - Macros to simplify query building and reduce boilerplate.
 - query
 - Query builder implementation for filtering, selecting, ordering, grouping, and aggregating data.
 - queryable
 - Queryable trait for supporting multiple container types.
 
Macros§
- avg_
where  - Quick average aggregation.
 - collect_
lazy  - Creates a lazy query and collects results in one line.
 - count_
where  - Quick count with filter.
 - exists_
where  - Check if any item matches.
 - filter
 - Simplified where_ macro that reduces boilerplate.
 - filter_
collect  - Quick filter and collect.
 - find_
first  - Find first matching item.
 - lazy_
query  - Creates a lazy query with multiple filters in a concise syntax.
 - paginate
 - Quick pagination.
 - query
 - Creates a Query with multiple filters in a concise syntax.
 - select_
all  - Select and collect in one line.
 - select_
where  - Select with filter.
 - sum_
where  - Quick sum aggregation.
 
Structs§
- Join
Query  - A query builder for joining two collections.
 - Lazy
Query  - A lazy query builder that uses iterators for deferred execution.
 - Lock
Join Query  - A join query builder for locked data structures.
 - Lock
Lazy Query  - Lazy query for locked data with early termination.
 - Lock
Query  - A query builder for locked data structures.
 - Lock
View  - A reusable query pattern (like a SQL VIEW).
 - Locked
Value Ref  - A reference to a value behind a lock.
 - Materialized
Lock View  - Materialized view - a cached query result.
 - Query
 - A query builder for filtering, selecting, ordering, grouping, and aggregating data.
 - Query
With Skip  - Helper struct for pagination after a skip operation.
 
Enums§
- KeyPaths
 - Go to examples section to see the implementations
 
Traits§
- Lock
Iter Ext  - Extension methods for lock iterators.
 - Lock
Joinable  - Helper trait for creating join queries from locked collections.
 - Lock
Joinable Collection  - Helper trait for collections that can participate in joins.
 - Lock
Lazy Queryable  - Extension trait for creating lazy lock queries.
 - Lock
Query Ext  - Extension trait for querying collections of locks.
 - Lock
Queryable  - Helper to create LockQuery from HashMap.
 - Lock
Value  - Helper trait for lock-aware value extraction.
 - Query
Ext  - Extension trait that adds eager Query methods directly to slice-like containers
 - Queryable
 - Trait for types that can be queried.
 - Queryable
Ext  - Extension trait for Queryable types that provides query building capabilities.
 
Derive Macros§
- Keypath
 - Query
Builder  - Derive macro to generate helper methods for query building
 - Queryable
Derive  - Derive macro to generate Queryable implementations