Skip to main content

drizzle_types/
lib.rs

1//! Shared type definitions for Drizzle ORM
2//!
3//! This crate provides common type definitions used across multiple Drizzle crates,
4//! including:
5//!
6//! - [`Dialect`] - Database dialect enum (`SQLite`, `PostgreSQL`, `MySQL`)
7//! - `SQLite` types in the [`sqlite`] module
8//! - `PostgreSQL` types in the [`postgres`] module
9//! - `MySQL` types in the [`mysql`] module
10//!
11//! # Features
12//!
13//! - `std` - Standard library support (enabled by default)
14//! - `alloc` - Allocator support for `no_std` environments
15//! - `uuid` - Enable UUID type support
16//! - `serde` - Enable serde serialization/deserialization
17//! - `chrono` - Enable chrono date/time type support
18//! - `time` - Enable time crate type support
19//! - `geo-types` - Enable geometric type support
20//! - `cidr` - Enable network address type support
21//! - `bit-vec` - Enable bit vector type support
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/// Prelude module for commonly used types
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}