strut_database/
lib.rs

1#![doc = include_str!("../README.md")]
2#![deny(missing_docs)]
3#![cfg_attr(test, deny(warnings))]
4
5// Compile time check to ensure no more than one default database type is active
6#[cfg(any(
7    all(
8        feature = "default-mysql",
9        any(feature = "default-postgres", feature = "default-sqlite"),
10    ),
11    all(
12        feature = "default-postgres",
13        any(feature = "default-mysql", feature = "default-sqlite"),
14    ),
15    all(
16        feature = "default-sqlite",
17        any(feature = "default-mysql", feature = "default-postgres"),
18    ),
19))]
20compile_error!(
21    "No more than one of the following feature flags may be enabled at a time: `default-mysql`, `default-postgres`, `default-sqlite`."
22);
23
24/// Exposes the data structures used in the configuration section.
25mod repr {
26    pub mod cert;
27    pub mod handle;
28    pub mod log;
29    pub mod pool;
30}
31#[cfg(feature = "mysql")]
32pub use self::repr::handle::mysql::{MySqlHandle, MySqlHandleCollection};
33#[cfg(feature = "postgres")]
34pub use self::repr::handle::postgres::{PostgresHandle, PostgresHandleCollection};
35#[cfg(feature = "sqlite")]
36pub use self::repr::handle::sqlite::{SqliteHandle, SqliteHandleCollection};
37
38/// Exposes an application configuration section.
39mod config;
40pub use self::config::DatabaseConfig;
41
42/// Exposes machinery for maintaining a pool of connections.
43mod connector;
44pub use self::connector::Connector;
45
46/// Implements a migrations worker.
47mod migrations;
48pub use self::migrations::MigrationsWorker;
49pub use strut_sync::Gate;
50
51/// Re-exports the public API of `sqlx` for convenience.
52pub use sqlx;
53
54
55/// Re-exports the `strut_shutdown` function to facilitate stand-alone usage of
56/// this crate.
57///
58/// When using this crate without the `strut` crate itself, await on this
59/// function as a last thing before completing the main application logic.
60pub use strut_core::strut_shutdown;