1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
//! # `🌍 Atmosphere`
//!
//! **A lightweight sql framework for sustainable database reliant systems**
//!
//! ## Overview
//!
//! Atmosphere is a lightweight SQL framework designed for sustainable, database-reliant systems.
//! It leverages Rust's powerful type and macro systems to derive SQL schemas from your rust struct
//! definitions into an advanced trait system.
//!
//! Atmosphere provides a suite of modules and types that abstract and facilitate various aspects
//! of database operations, from query construction and execution to error handling and schema
//! management.
//!
//! ## Key Features
//!
//! - SQL schema derivation from Rust structs.
//! - Advanced trait system for query generation.
//! - Automated database code testing with `atmosphere::testing`
//! - ORM-like CRUD traits.
//! - Code reusability across API layers using generics.
//! - Compile-time introspection for type-safe schema generation.
#[cfg(any(
    feature = "any",
    feature = "mysql",
    feature = "postgres",
    feature = "sqlite"
))]
/// Facilitates binding entities to queries, ensuring type safety and ease of use in query construction.
pub mod bind;
#[cfg(any(
    feature = "any",
    feature = "mysql",
    feature = "postgres",
    feature = "sqlite"
))]
/// Defines high-level database error types, offering a structured approach to error handling.
pub mod error;
#[cfg(any(
    feature = "any",
    feature = "mysql",
    feature = "postgres",
    feature = "sqlite"
))]
/// Implements a hook system, allowing custom logic to be executed at different stages of database
/// interactions.
#[cfg(any(
    feature = "any",
    feature = "mysql",
    feature = "postgres",
    feature = "sqlite"
))]
pub mod hooks;
#[cfg(any(
    feature = "any",
    feature = "mysql",
    feature = "postgres",
    feature = "sqlite"
))]
/// Offers an abstraction layer for building and executing SQL queries, simplifying complex query
/// logic.
pub mod query;
#[cfg(any(
    feature = "any",
    feature = "mysql",
    feature = "postgres",
    feature = "sqlite"
))]
/// Models SQL relationships, providing tools to define and manipulate relationships between
/// database entities.
pub mod rel;
#[cfg(any(
    feature = "any",
    feature = "mysql",
    feature = "postgres",
    feature = "sqlite"
))]
/// Manages the runtime environment for database operations, encompassing execution contexts and
/// configurations.
pub mod runtime;
#[cfg(any(
    feature = "any",
    feature = "mysql",
    feature = "postgres",
    feature = "sqlite"
))]
/// Contains compile-time generated SQL schema traits, enabling a declarative approach to schema
/// definition.
pub mod schema;
#[cfg(any(
    feature = "any",
    feature = "mysql",
    feature = "postgres",
    feature = "sqlite"
))]
/// Provides utilities for automated testing of SQL interactions, ensuring reliability and
/// correctness of database operations.
pub mod testing;
#[cfg(any(
    feature = "any",
    feature = "mysql",
    feature = "postgres",
    feature = "sqlite"
))]
pub use driver::{Driver, Pool};
/// Driver System
///
/// The default driver / feature `any` is activated by default. If a specific driver
/// feature is enabled (`postgres`, `sqlite`, `mysql`) atmosphere will prefer this over
/// the `sqlx::Any` driver.
///
/// If your application makes use of more than one database at the same time, please use the any
/// driver.
pub mod driver {
    #[cfg(any(
        all(feature = "postgres", any(feature = "mysql", feature = "sqlite")),
        all(feature = "mysql", any(feature = "postgres", feature = "sqlite")),
        all(feature = "sqlite", any(feature = "postgres", feature = "mysql")),
    ))]
    compile_error!("only one database driver can be set – please choose only the `any` driver if you need more than one database");
    #[cfg(all(
        feature = "any",
        all(
            not(feature = "mysql"),
            not(feature = "postgres"),
            not(feature = "sqlite")
        )
    ))]
    /// Atmosphere Database Driver
    pub type Driver = sqlx::Any;
    #[cfg(all(
        feature = "any",
        all(
            not(feature = "mysql"),
            not(feature = "postgres"),
            not(feature = "sqlite")
        )
    ))]
    /// Atmosphere Database Pool
    pub type Pool = sqlx::AnyPool;
    #[cfg(all(feature = "postgres", not(any(feature = "mysql", feature = "sqlite"))))]
    /// Atmosphere Database Driver
    pub type Driver = sqlx::Postgres;
    #[cfg(all(feature = "postgres", not(any(feature = "mysql", feature = "sqlite"))))]
    /// Atmosphere Database Pool
    pub type Pool = sqlx::PgPool;
    #[cfg(all(feature = "mysql", not(any(feature = "postgres", feature = "sqlite"))))]
    /// Atmosphere Database Driver
    pub type Driver = sqlx::MySql;
    #[cfg(all(feature = "mysql", not(any(feature = "postgres", feature = "sqlite"))))]
    /// Atmosphere Database Pool
    pub type Pool = sqlx::MySqlPool;
    #[cfg(all(feature = "sqlite", not(any(feature = "postgres", feature = "mysql"))))]
    /// Atmosphere Database Driver
    pub type Driver = sqlx::Sqlite;
    #[cfg(all(feature = "sqlite", not(any(feature = "postgres", feature = "mysql"))))]
    /// Atmosphere Database Pool
    pub type Pool = sqlx::SqlitePool;
    #[cfg(all(
        not(feature = "any"),
        not(feature = "postgres"),
        not(feature = "mysql"),
        not(feature = "sqlite")
    ))]
    compile_error!(
        "you must chose a atmosphere database driver (available: any, postgres, mysql, sqlite)"
    );
}
#[cfg(any(
    feature = "any",
    feature = "mysql",
    feature = "postgres",
    feature = "sqlite"
))]
pub use bind::*;
#[cfg(any(
    feature = "any",
    feature = "mysql",
    feature = "postgres",
    feature = "sqlite"
))]
pub use error::*;
#[cfg(any(
    feature = "any",
    feature = "mysql",
    feature = "postgres",
    feature = "sqlite"
))]
pub use schema::*;
#[doc(hidden)]
pub use sqlx;