Skip to main content

rustauth_diesel/
lib.rs

1//! Diesel database adapters for RustAuth.
2//!
3//! ## Row decoding strategy
4//!
5//! **Chosen:** dynamic row capture via [`postgres::row::DieselPostgresRow`], which
6//! implements [`diesel::deserialize::QueryableByName`] by storing raw column bytes
7//! and type OIDs at build time, then decoding through `tokio_postgres` [`FromSql`]
8//! in the shared [`SqlRowReader`] boundary.
9//!
10//! Direct [`diesel::row::NamedRow`] decoding remains available for feasibility tests
11//! in [`row`].
12//!
13//! ## Adapter shape
14//!
15//! - Crate name: `rustauth-diesel` (async-only on `diesel-async`; no sync adapter).
16//! - Initial backends: Postgres and MySQL (`postgres` / `mysql` features).
17//! - SQLite and sync Diesel are deferred by design.
18
19#![cfg(any(feature = "postgres", feature = "mysql"))]
20
21pub(crate) mod migration;
22mod stores;
23
24mod bind;
25mod row;
26
27#[cfg(feature = "postgres")]
28mod postgres;
29
30#[cfg(feature = "mysql")]
31mod mysql;
32
33#[cfg(feature = "mysql")]
34pub use bind::bind_mysql_params;
35#[cfg(feature = "postgres")]
36pub use bind::bind_postgres_params;
37
38#[cfg(feature = "mysql")]
39pub use row::decode_mysql_row;
40#[cfg(feature = "postgres")]
41pub use row::decode_postgres_row;
42
43pub use row::RowDecodeStrategy;
44
45#[cfg(feature = "postgres")]
46pub use postgres::{DieselPostgresAdapter, DieselPostgresRateLimitStore};
47
48#[cfg(feature = "mysql")]
49pub use mysql::{DieselMysqlAdapter, DieselMysqlRateLimitStore};
50
51#[cfg(feature = "postgres")]
52pub use stores::{DieselPostgresStores, DieselPostgresStoresBuilder};
53
54#[cfg(feature = "mysql")]
55pub use stores::{DieselMysqlStores, DieselMysqlStoresBuilder};
56
57pub(crate) use rustauth_core::db::{
58    consume_sql_rate_limit_record as consume_record, rate_limit_count_from_i64 as count_from_i64,
59    rate_limit_count_to_i64 as count_to_i64, SqlRateLimitNames as RateLimitSqlNames,
60};
61
62#[cfg(not(any(feature = "postgres", feature = "mysql")))]
63compile_error!("enable at least one of `postgres` or `mysql` features");