rust_queries_core/lib.rs
1//! # Rust Query Builder Core
2//!
3//! Core functionality for rust-queries-builder - a powerful, type-safe query builder
4//! library for Rust that leverages key-paths for SQL-like operations on in-memory collections.
5//!
6//! This crate contains the core query building logic, without proc-macros or derive functionality.
7//!
8//! ## Features
9//!
10//! - Type-safe queries with compile-time checking
11//! - SQL-like operations: WHERE, SELECT, ORDER BY, GROUP BY, JOIN
12//! - Rich aggregations: COUNT, SUM, AVG, MIN, MAX
13//! - Pagination: LIMIT and SKIP
14//! - Join operations: INNER, LEFT, RIGHT, CROSS
15//! - Zero-cost abstractions
16//! - Clone-free operations
17//! - Lazy evaluation with early termination
18//! - Extension traits for ergonomic API
19//! - Helper macros to reduce boilerplate
20//!
21//! ## Example
22//!
23//! ```rust
24//! use rust_queries_core::{Query, QueryExt};
25//! use key_paths_derive::Keypaths;
26//!
27//! #[derive(Keypaths)]
28//! struct Product {
29//! id: u32,
30//! name: String,
31//! price: f64,
32//! }
33//!
34//! let products = vec![
35//! Product { id: 1, name: "Laptop".to_string(), price: 999.99 },
36//! Product { id: 2, name: "Mouse".to_string(), price: 29.99 },
37//! ];
38//!
39//! // Using extension trait
40//! let query = products.query().where_(Product::price_r(), |&p| p > 100.0);
41//! let expensive = query.all();
42//! ```
43
44pub mod query;
45pub mod join;
46pub mod lazy;
47pub mod queryable;
48pub mod ext;
49pub mod datetime;
50pub mod locks;
51pub mod lock_query;
52pub mod lock_lazy;
53pub mod lock_join;
54pub mod lock_view;
55pub mod lock_ext;
56
57#[macro_use]
58pub mod macros;
59
60pub use query::{Query, QueryWithSkip};
61pub use join::JoinQuery;
62pub use lazy::LazyQuery;
63pub use queryable::Queryable;
64pub use ext::{QueryExt, QueryableExt};
65pub use locks::{LockValue, LockQueryExt, LockIterExt, LockedValueRef};
66pub use lock_query::{LockQuery, LockQueryable, LockLazyQueryable};
67pub use lock_lazy::LockLazyQuery;
68pub use lock_join::{LockJoinQuery, LockJoinable, LockJoinableCollection};
69pub use lock_view::{LockView, MaterializedLockView};
70
71// Re-export lock extensions for parking_lot and tokio
72#[cfg(feature = "parking_lot")]
73pub use lock_ext::{
74 ParkingLotRwLockWrapper, ParkingLotMutexWrapper,
75 ParkingLotQueryExt, ParkingLotMutexQueryExt,
76 ParkingLotJoinExt, ParkingLotMutexJoinExt,
77};
78
79#[cfg(feature = "tokio")]
80pub use lock_ext::{
81 TokioRwLockWrapper, TokioMutexWrapper,
82 TokioLockQueryExt, TokioMutexQueryExt,
83 TokioLockJoinExt, TokioMutexJoinExt,
84};
85
86// Re-export key-paths for convenience
87pub use key_paths_core::KeyPaths;