rust_queries_builder/
lib.rs

1//! # Rust Query Builder
2//!
3//! A powerful, type-safe query builder library for Rust that leverages key-paths
4//! for SQL-like operations on in-memory collections.
5//!
6//! ## Features
7//!
8//! - **Type-safe queries**: Compile-time type checking using key-paths
9//! - **SQL-like operations**: WHERE, SELECT, ORDER BY, GROUP BY, JOIN
10//! - **Aggregations**: COUNT, SUM, AVG, MIN, MAX
11//! - **Pagination**: LIMIT and SKIP operations
12//! - **Join operations**: INNER JOIN, LEFT JOIN with custom predicates
13//! - **Zero-cost abstractions**: Leverages Rust's zero-cost abstractions
14//!
15//! ## Example
16//!
17//! ```rust
18//! use rust_queries_builder::Query;
19//! use key_paths_derive::Keypaths;
20//!
21//! #[derive(Clone, Keypaths)]
22//! struct Product {
23//!     id: u32,
24//!     name: String,
25//!     price: f64,
26//!     category: String,
27//! }
28//!
29//! let products = vec![
30//!     Product { id: 1, name: "Laptop".to_string(), price: 999.99, category: "Electronics".to_string() },
31//!     Product { id: 2, name: "Mouse".to_string(), price: 29.99, category: "Electronics".to_string() },
32//! ];
33//!
34//! // Filter products by category and price
35//! let affordable = Query::new(&products)
36//!     .where_(Product::category_r(), |cat| cat == "Electronics")
37//!     .where_(Product::price_r(), |&price| price < 100.0)
38//!     .all();
39//!
40//! // Order by price
41//! let sorted = Query::new(&products)
42//!     .order_by_float(Product::price_r());
43//!
44//! // Aggregate
45//! let total = Query::new(&products)
46//!     .sum(Product::price_r());
47//! ```
48
49pub mod query;
50pub mod join;
51pub mod lazy;
52pub mod queryable;
53pub mod ext;
54
55#[macro_use]
56pub mod macros;
57
58pub use query::{Query, QueryWithSkip};
59pub use join::JoinQuery;
60pub use lazy::LazyQuery;
61pub use queryable::Queryable;
62pub use ext::QueryExt;
63
64// Re-export key-paths for convenience
65pub use key_paths_core::KeyPaths;
66
67// Re-export derive macros
68pub use rust_queries_derive::{Queryable as QueryableDerive, QueryBuilder};