#sql-query #query-builder #sql #keypaths

rust-queries-core

Core functionality for rust-queries-builder - type-safe query builder for Rust collections

13 releases (stable)

1.0.8 Nov 23, 2025
1.0.7 Oct 18, 2025
0.9.0 Oct 12, 2025
0.8.0 Oct 12, 2025
0.6.0 Oct 11, 2025

#2183 in Database interfaces


Used in rust-queries-builder

MIT/Apache

370KB
6K SLoC

rust-queries-builder

rust-queries-builder


lib.rs:

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::Keypath;

#[derive(Keypath)]
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(), |&p| p > 100.0);
let expensive = query.all();

Dependencies

~0.3–4.5MB
~81K SLoC