Skip to main content

drizzle_types/
lib.rs

1//! SQL type definitions shared by the drizzle crates.
2//!
3//! - [`sql`]: compile-time SQL type markers' capabilities ([`DataType`],
4//!   [`Compatible`], [`Assignable`], [`Numeric`], [`Textual`], ...), also
5//!   re-exported at the crate root.
6//! - [`sqlite`], [`postgres`], [`mysql`]: each dialect's type markers, column
7//!   types and DDL definitions.
8//! - [`Dialect`]: names a database.
9//! - [`MigrationTracking`], [`ConfigValue`], [`Casing`]: migration settings.
10//!
11//! # Features
12//!
13//! - `std` (default): standard library support.
14//! - `alloc`: `no_std` with an allocator. Without `std` or `alloc`, only
15//!   [`Dialect`] is available.
16//! - `serde`, `schemars`: serialization and JSON Schema for the DDL types.
17//! - `uuid`, `chrono`, `geo-types`, `cidr`, `bit-vec`: add the column types
18//!   and Rust type mappings for those crates. `time` is accepted but
19//!   currently adds nothing.
20//! - `col16`, `col32`, `col64`, `col128`, `col200`: allow row-value tuples of
21//!   up to that many columns (8 by default).
22
23#![cfg_attr(not(feature = "std"), no_std)]
24
25#[cfg(all(feature = "alloc", not(feature = "std")))]
26extern crate alloc;
27
28// Internal prelude for std/alloc compatibility
29#[allow(unused_imports)]
30pub(crate) mod alloc_prelude {
31    #[cfg(feature = "std")]
32    pub use std::{
33        borrow::Cow,
34        boxed::Box,
35        format,
36        string::{String, ToString},
37        vec,
38        vec::Vec,
39    };
40
41    #[cfg(all(feature = "alloc", not(feature = "std")))]
42    pub use alloc::{
43        borrow::Cow,
44        boxed::Box,
45        format,
46        string::{String, ToString},
47        vec,
48        vec::Vec,
49    };
50}
51
52mod dialect;
53#[cfg(any(feature = "std", feature = "alloc"))]
54mod migration;
55#[cfg(any(feature = "std", feature = "alloc"))]
56pub mod mysql;
57#[cfg(any(feature = "std", feature = "alloc"))]
58pub mod postgres;
59#[cfg(any(feature = "std", feature = "alloc"))]
60pub mod serde_helpers;
61#[cfg(any(feature = "std", feature = "alloc"))]
62pub mod sql;
63#[cfg(any(feature = "std", feature = "alloc"))]
64pub mod sqlite;
65
66pub use dialect::{Dialect, DialectParseError};
67#[cfg(feature = "std")]
68pub use migration::ConfigValueError;
69#[cfg(any(feature = "std", feature = "alloc"))]
70pub use migration::{Casing, ConfigValue, MigrationTracking};
71#[cfg(any(feature = "std", feature = "alloc"))]
72pub use sql::*;
73
74/// The dialect enum and each dialect's column-type and category enums.
75pub mod prelude {
76    pub use crate::Dialect;
77    #[cfg(any(feature = "std", feature = "alloc"))]
78    pub use crate::mysql::{MySQLType, MySQLTypeCategory, TypeCategory as MySQLRustTypeCategory};
79    #[cfg(any(feature = "std", feature = "alloc"))]
80    pub use crate::postgres::{PgTypeCategory, PostgreSQLType, TypeCategory as PgRustTypeCategory};
81    #[cfg(any(feature = "std", feature = "alloc"))]
82    pub use crate::sqlite::{SQLTypeCategory, SQLiteType, TypeCategory as SqliteRustTypeCategory};
83}