Skip to main content

Crate ruprizzle

Crate ruprizzle 

Source
Expand description

The ruprizzle runtime: the crate your application depends on.

This crate provides the types that generated code compiles against: typed Columns, Filters, 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.

Re-exports§

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

Modules§

aggregate
Typed aggregate expressions.
cache
Query Result Caching with TTL and Tag Invalidation.
col
Typed column tokens.
error
Runtime errors.
executor
The Executor abstraction over a pool and a transaction.
filter
Filter algebra and constructors.
hierarchy
Tree hierarchy queries and data structures powered by recursive CTEs.
include
Batched relation include loading.
join
Join result types and offset-aware decoding.
json
JSON path and typed JSON column tokens.
m2m
Many-to-many relation mutations: attach, set, and detach target rows through an explicit join model.
metrics
Metrics facade for ruprizzle.
model
The Model trait that generated entities implement.
order
Order-by tokens.
page
Pagination results.
pool
Connection pool construction, replica routing, and configuration.
prelude
Common imports for application code.
query
Query builders.
query_manifest
Optional query-manifest recorder for offline validation.
rel
One-to-many relation mutations: connect, disconnect, set, and cascade.
related
Relation wrapper that distinguishes “not loaded” from “loaded and empty”.
rusqlite
Native rusqlite backend for the ruprizzle runtime.
spatial
PostGIS and Geospatial Scalar Types for Ruprizzle.
tokio_postgres
Native tokio-postgres backend for the ruprizzle runtime.
tx
Transaction handle.
types
Re-exported database types (chrono, uuid, decimal, json, …) so generated code can depend on ruprizzle alone.
value
Owned values bound to SQL queries.

Macros§

raw
Builds an injection-safe raw SQL fragment.
tokio_postgres_default_row
Convenience macro for tests and examples: implement FromTokioPostgresRow by returning Default::default().

Structs§

CompiledSql
A compiled SQL statement and its bound values.
CountingExecutor
Wraps an executor and counts every statement that reaches it.
NestedConnectOrCreate
A specification for nested connect_or_create operations.
NestedCreate
A builder for creating a nested child entity.
NestedRelWrite
A nested write specification on model M targeting child relation C.
OffsetRow
A view into a concrete sqlx row where column 0 is the column at offset of the original row.
PlanCache
A thread-safe key → SQL string map.

Enums§

RelNestedOp
An atomic operation on a one-to-many or one-to-one child relation.

Traits§

AnyNestedWrite
Object-safe interface for any nested write attached to a parent model M.

Functions§

delete
Compile a DELETE for M.
dialect_for_pool
Build a &'static dyn DbDialect from a Pool.
insert
Compile an INSERT for M.
insert_many
Compile a multi-row INSERT for M.
sanitize_sql
Sanitizes a SQL string by stripping literal values (strings, numbers) to ensure PII safety.
select
Compile a SELECT for M.
update
Compile an UPDATE for M.

Type Aliases§

BoxFuture
A boxed future, used by the transaction escape hatch.