ruprizzle 1.6.0

A schema-first ORM for Rust: typed queries, relations, and automatic migrations
Documentation
//! The ruprizzle runtime: the crate your application depends on.
//!
//! This crate provides the types that generated code compiles against: typed
//! [`Column`]s, [`Filter`]s, [`Related`] wrappers, and the query builders that
//! produce [`CompiledSql`]. It also owns connection pooling ([`Pool`]),
//! transactions ([`Tx`]), and query execution ([`Executor`]). Migrations live in
//! the separate `ruprizzle-migrate` crate, which the CLI depends on directly —
//! this crate does not re-export it.
//!
//! # Backends
//!
//! By default `ruprizzle` builds on `sqlx::Any`, which lets the same binary talk
//! to PostgreSQL, MySQL/MariaDB, and SQLite. You can opt into native-driver paths:
//!
//! * **`sqlite-rusqlite`** — a synchronous `rusqlite` backend that skips the
//!   `sqlx::Any` text round-trip for SQLite. Enable it in `Cargo.toml` and use a
//!   `driver=rusqlite` query parameter on the SQLite URL.
//! * **`postgres-tokio-postgres`** — experimental native `tokio-postgres`
//!   backend behind the matching feature flag.
//!
//! The public API is identical across backends. Use the typed `Pool::as_any`,
//! `Pool::as_sqlite`, `Pool::as_postgres`, and feature-gated `Pool::as_rusqlite`
//! / `Pool::as_tokio_postgres` accessors when you need driver-specific behaviour.
//!
//! # Prelude
//!
//! Most application code can start with [`prelude`].

#![forbid(unsafe_code)]
#![warn(missing_docs, clippy::all)]

pub mod aggregate;
pub mod cache;
pub mod col;
#[doc(hidden)]
pub mod compile;
#[doc(hidden)]
pub mod counting;
pub mod error;
pub mod executor;
pub mod filter;
pub mod hierarchy;
pub mod include;
pub mod join;
pub mod json;
pub mod m2m;
pub mod metrics;
pub mod model;
#[doc(hidden)]
pub mod nested;
#[doc(hidden)]
pub mod offset_row;
pub use offset_row::OffsetRow;
pub mod order;
pub mod page;
pub mod pool;
pub mod query;
pub mod query_manifest;
pub mod rel;
pub mod related;
#[cfg(feature = "sqlite-rusqlite")]
pub mod rusqlite;
pub mod spatial;
#[cfg(feature = "postgres-tokio-postgres")]
pub mod tokio_postgres;
pub mod tx;
pub mod value;

/// Re-exported database types (chrono, uuid, decimal, json, ...) so generated
/// code can depend on `ruprizzle` alone.
pub mod types {
    pub use sqlx::types::*;
}

/// Decoding helpers for generated `FromRow` implementations.
#[doc(hidden)]
pub mod decode;

/// Common imports for application code.
pub mod prelude {
    pub use crate::{
        Aggregate, AggregateQuery, AggregateScalar, Column, Cte, CteQuery, Encodable, Error,
        Executor, Filter, GroupBy, GroupedQuery, HierarchyDirection, HierarchyNode, HierarchyQuery,
        InMemoryCache, InsertQuery, IsolationLevel, Join2, JoinKind, JoinOn, JsonColumn, LeftJoin2,
        LineString, LoadBalancing, Maybe, Model, MultiPolygon, NestedConnectOrCreate, NestedCreate,
        NestedRelWrite, Numeric, OrderBy, Page, Point, Polygon, Pool, QueryCache, RawFragment,
        RelNestedOp, Related, ReplicaPool, RoutedPool, RoutedPoolBuilder, SelectQuery, SetOp,
        SetOpQuery, Tx, Value, raw,
    };
}

pub use aggregate::{
    Aggregate, AggregateEntry, AggregateKind, AggregateScalar, AggregateSet, GroupBy,
    IntoAggregate, Numeric,
};
pub use cache::{InMemoryCache, QueryCache};
pub use col::{Column, Projection};
pub use compile::{
    CompiledSql, PlanCache, delete, dialect_for_pool, insert, insert_many, sanitize_sql, select,
    update,
};
pub use counting::CountingExecutor;
pub use error::Error;
pub use executor::{Executor, RowBatch, decode_rows};
pub use filter::{
    Cte, CteQuery, ExistsSubquery, Filter, FilterNode, JsonFilterOp, RawFragment, SpatialOp,
    Subquery, all, any,
};
pub use hierarchy::{HierarchyDirection, HierarchyNode, HierarchyQuery};
pub use include::{IncludeList, IncludeMany, IncludeOne, IncludeSet};
pub use join::{Join2, JoinKind, JoinOn, JoinSide, LeftJoin2, Maybe};
pub use json::{JsonColumn, JsonPath, JsonSet};
pub use m2m::{M2mAction, M2mWrite};
pub use model::Model;
pub use nested::{
    AnyNestedWrite, NestedConnectOrCreate, NestedCreate, NestedRelWrite, RelNestedOp,
};
pub use order::OrderBy;
pub use page::Page;
pub use pool::{
    HealthCheckTask, LoadBalancing, Pool, PoolConfig, PoolStats, ReplicaPool, RoutedPool,
    RoutedPoolBuilder, connect, connect_with, ping, stats,
};
pub use query::{
    AggregateQuery, DeleteQuery, GroupedQuery, InsertManyQuery, InsertQuery, NestedSetter,
    SelectQuery, SetOp, SetOpQuery, UpdateQuery,
};
pub use rel::{DeleteAction, DeleteCascade, RelAction, RelWrite};
pub use related::Related;
pub use ruprizzle_macros::raw;
pub use serde;
pub use serde_json;
pub use spatial::{LineString, MultiPolygon, Point, Polygon};
pub use sqlx;
pub use tx::{IsolationLevel, Savepoint, Tx, is_retryable};
pub use value::{Encodable, Ordered, Value};

/// A boxed future, used by the transaction escape hatch.
pub type BoxFuture<'a, T> = std::pin::Pin<Box<dyn std::future::Future<Output = T> + Send + 'a>>;