Skip to main content

toolu_orm/
lib.rs

1//! Single entry point for the toolu-orm workspace.
2//!
3//! `toolu-orm` is a facade: it contains no logic of its own, only re-exports
4//! of the four library crates, all pinned to one version.
5//!
6//! ```toml
7//! toolu-orm = { version = "0.1", features = ["postgres"] }
8//! ```
9//!
10//! | Re-export | Crate | Holds |
11//! |---|---|---|
12//! | [`core`] | `toolu-orm-core` | schema, columns, migrations, driver traits |
13//! | [`query`] | `toolu-orm-query` | select / insert / update / delete builders |
14//! | [`connection`] | `toolu-orm-connection` | pools and driver adapters |
15//! | [`table`], [`ColumnEnum`], [`FromRow`], [`Relational`] | `toolu-orm-macros` | proc macros |
16//!
17//! ## Features
18//!
19//! `libsql`, `rusqlite` and `postgres` forward to every re-exported crate, so
20//! one feature list drives the whole stack. Enable exactly one: `toolu-orm-query`
21//! compiles its executor and transaction code only for a single driver.
22//!
23//! ## Prelude
24//!
25//! The proc macros expand to paths that name `toolu_orm_core` (and, for the
26//! generated query builders, `toolu_orm_query`) directly. Depending on
27//! `toolu-orm` alone does not put those crate names in scope, so import the
28//! [`prelude`] in every module that uses `#[table]` or a derive:
29//!
30//! ```ignore
31//! use toolu_orm::prelude::*;
32//!
33//! #[table("users")]
34//! pub struct User {
35//!   pub id: i64,
36//!   pub email: String,
37//! }
38//! ```
39
40pub use toolu_orm_connection as connection;
41pub use toolu_orm_core as core;
42pub use toolu_orm_query as query;
43
44pub use toolu_orm_macros::{table, ColumnEnum, FromRow, Relational};
45
46/// Everything a module needs to expand `#[table]` and the derives.
47///
48/// Glob-import this. Beyond the macros themselves it re-exports the crate
49/// names the expansions refer to — `toolu_orm_core`, `toolu_orm_query`, and
50/// the driver crate for the enabled feature — which a dependency on
51/// `toolu-orm` alone would not bring into scope.
52pub mod prelude {
53  pub use toolu_orm_core;
54  pub use toolu_orm_query;
55
56  pub use toolu_orm_macros::{table, ColumnEnum, FromRow, Relational};
57
58  #[cfg(feature = "libsql")]
59  pub use toolu_orm_core::libsql;
60  #[cfg(feature = "rusqlite")]
61  pub use toolu_orm_core::rusqlite;
62  #[cfg(feature = "postgres")]
63  pub use toolu_orm_core::tokio_postgres;
64}