atmosphere_core/
lib.rs

1//! # `🌍 Atmosphere`
2//!
3//! **A lightweight sql framework for sustainable database reliant systems**
4//!
5//! ## Overview
6//!
7//! Atmosphere is a lightweight SQL framework designed for sustainable, database-reliant systems.
8//! It leverages Rust's powerful type and macro systems to derive SQL schemas from your rust struct
9//! definitions into an advanced trait system.
10//!
11//! Atmosphere provides a suite of modules and types that abstract and facilitate various aspects
12//! of database operations, from query construction and execution to error handling and schema
13//! management.
14//!
15//! ## Key Features
16//!
17//! - SQL schema derivation from Rust structs.
18//! - Advanced trait system for query generation.
19//! - Automated database code testing with `atmosphere::testing`
20//! - ORM-like CRUD traits.
21//! - Code reusability across API layers using generics.
22//! - Compile-time introspection for type-safe schema generation.
23
24#![cfg(any(feature = "postgres", feature = "mysql", feature = "sqlite"))]
25
26/// Facilitates binding entities to queries, ensuring type safety and ease of use in query construction.
27pub mod bind;
28/// Defines high-level database error types, offering a structured approach to error handling.
29pub mod error;
30/// Implements a hook system, allowing custom logic to be executed at different stages of database
31/// interactions.
32pub mod hooks;
33/// Offers an abstraction layer for building and executing SQL queries, simplifying complex query
34/// logic.
35pub mod query;
36/// Models SQL relationships, providing tools to define and manipulate relationships between
37/// database entities.
38pub mod rel;
39/// Manages the runtime environment for database operations, encompassing execution contexts and
40/// configurations.
41pub mod runtime;
42/// Contains compile-time generated SQL schema traits, enabling a declarative approach to schema
43/// definition.
44pub mod schema;
45/// Provides utilities for automated testing of SQL interactions, ensuring reliability and
46/// correctness of database operations.
47pub mod testing;
48
49pub use driver::{Driver, Pool};
50
51/// Driver System
52///
53/// The default driver / feature `any` is activated by default. If a specific driver
54/// feature is enabled (`postgres`, `sqlite`, `mysql`) atmosphere will prefer this over
55/// the `sqlx::Any` driver.
56///
57/// If your application makes use of more than one database at the same time, please use the any
58/// driver.
59pub mod driver {
60    #[cfg(any(
61        all(feature = "postgres", any(feature = "mysql", feature = "sqlite")),
62        all(feature = "mysql", any(feature = "postgres", feature = "sqlite")),
63        all(feature = "sqlite", any(feature = "postgres", feature = "mysql")),
64    ))]
65    compile_error!(
66        "only one database driver can be set – please use multiple binaries using different atmosphere features if you need more than one database"
67    );
68
69    #[cfg(all(feature = "postgres", not(any(feature = "mysql", feature = "sqlite"))))]
70    /// Atmosphere Database Driver
71    pub type Driver = sqlx::Postgres;
72
73    #[cfg(all(feature = "postgres", not(any(feature = "mysql", feature = "sqlite"))))]
74    /// Atmosphere Database Pool
75    pub type Pool = sqlx::PgPool;
76
77    #[cfg(all(feature = "mysql", not(any(feature = "postgres", feature = "sqlite"))))]
78    /// Atmosphere Database Driver
79    pub type Driver = sqlx::MySql;
80
81    #[cfg(all(feature = "mysql", not(any(feature = "postgres", feature = "sqlite"))))]
82    /// Atmosphere Database Pool
83    pub type Pool = sqlx::MySqlPool;
84
85    #[cfg(all(feature = "sqlite", not(any(feature = "postgres", feature = "mysql"))))]
86    /// Atmosphere Database Driver
87    pub type Driver = sqlx::Sqlite;
88
89    #[cfg(all(feature = "sqlite", not(any(feature = "postgres", feature = "mysql"))))]
90    /// Atmosphere Database Pool
91    pub type Pool = sqlx::SqlitePool;
92}
93
94pub use bind::*;
95pub use error::*;
96pub use schema::*;
97
98#[doc(hidden)]
99pub use sqlx;