Crate rust_queries_core

Crate rust_queries_core 

Source
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;
pub use ext::QueryableExt;
pub use locks::LockValue;
pub use locks::LockQueryExt;
pub use locks::LockIterExt;
pub use locks::LockedValueRef;
pub use lock_query::LockQuery;
pub use lock_query::LockQueryable;
pub use lock_query::LockLazyQueryable;
pub use lock_lazy::LockLazyQuery;
pub use lock_join::LockJoinQuery;
pub use lock_join::LockJoinable;
pub use lock_join::LockJoinableCollection;
pub use lock_view::LockView;
pub use lock_view::MaterializedLockView;

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.

Enums§

KeyPaths
Go to examples section to see the implementations