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//!
10//! # Features
11//!
12//! - `std` - Standard library support (enabled by default)
13//! - `alloc` - Allocator support for `no_std` environments
14//! - `uuid` - Enable UUID type support
15//! - `serde` - Enable serde serialization/deserialization
16//! - `chrono` - Enable chrono date/time type support
17//! - `time` - Enable time crate type support
18//! - `geo-types` - Enable geometric type support
19//! - `cidr` - Enable network address type support
20//! - `bit-vec` - Enable bit vector type support
21
22#![cfg_attr(not(feature = "std"), no_std)]
23
24#[cfg(all(feature = "alloc", not(feature = "std")))]
25extern crate alloc;
26
27// Internal prelude for std/alloc compatibility
28#[allow(unused_imports)]
29pub(crate) mod alloc_prelude {
30    #[cfg(feature = "std")]
31    pub use std::{
32        borrow::Cow,
33        boxed::Box,
34        format,
35        string::{String, ToString},
36        vec,
37        vec::Vec,
38    };
39
40    #[cfg(all(feature = "alloc", not(feature = "std")))]
41    pub use alloc::{
42        borrow::Cow,
43        boxed::Box,
44        format,
45        string::{String, ToString},
46        vec,
47        vec::Vec,
48    };
49}
50
51mod dialect;
52#[cfg(any(feature = "std", feature = "alloc"))]
53mod migration;
54#[cfg(any(feature = "std", feature = "alloc"))]
55pub mod postgres;
56#[cfg(any(feature = "std", feature = "alloc"))]
57pub mod serde_helpers;
58#[cfg(any(feature = "std", feature = "alloc"))]
59pub mod sql;
60#[cfg(any(feature = "std", feature = "alloc"))]
61pub mod sqlite;
62
63pub use dialect::{Dialect, DialectParseError};
64#[cfg(feature = "std")]
65pub use migration::EnvOrError;
66#[cfg(any(feature = "std", feature = "alloc"))]
67pub use migration::{Casing, EnvOr, MigrationTracking};
68#[cfg(any(feature = "std", feature = "alloc"))]
69pub use sql::*;
70
71/// Prelude module for commonly used types
72pub mod prelude {
73    pub use crate::Dialect;
74    #[cfg(any(feature = "std", feature = "alloc"))]
75    pub use crate::postgres::{PgTypeCategory, PostgreSQLType, TypeCategory as PgRustTypeCategory};
76    #[cfg(any(feature = "std", feature = "alloc"))]
77    pub use crate::sqlite::{SQLTypeCategory, SQLiteType, TypeCategory as SqliteRustTypeCategory};
78}