Expand description
§Rust Query Builder Core
Core functionality for rust-queries-builder - a powerful, type-safe query builder library for Rust that leverages key-paths for SQL-like operations on in-memory collections.
This crate contains the core query building logic, without proc-macros or derive functionality.
§Features
- Type-safe queries with compile-time checking
- SQL-like operations: WHERE, SELECT, ORDER BY, GROUP BY, JOIN
- Rich aggregations: COUNT, SUM, AVG, MIN, MAX
- Pagination: LIMIT and SKIP
- Join operations: INNER, LEFT, RIGHT, CROSS
- Zero-cost abstractions
- Clone-free operations
- Lazy evaluation with early termination
- Extension traits for ergonomic API
- Helper macros to reduce boilerplate
§Example
use rust_queries_core::{Query, QueryExt};
use key_paths_derive::Keypaths;
#[derive(Keypaths)]
struct Product {
id: u32,
name: String,
price: f64,
}
let products = vec![
Product { id: 1, name: "Laptop".to_string(), price: 999.99 },
Product { id: 2, name: "Mouse".to_string(), price: 29.99 },
];
// Using extension trait
let query = products.query().where_(Product::price_r(), |&p| p > 100.0);
let expensive = query.all();Re-exports§
pub use query::Query;pub use query::QueryWithSkip;pub use join::JoinQuery;pub use lazy::LazyQuery;pub use queryable::Queryable;pub use ext::QueryExt;
Modules§
- datetime
- DateTime operations for query builder.
- ext
- join
- Join query implementation for combining multiple collections.
- lazy
- Lazy query implementation using iterators.
- 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.
Enums§
- KeyPaths
- Go to examples section to see the implementations