drizzle_core/
lib.rs

1//! Drizzle Core - SQL generation library
2//!
3//! # no_std Support
4//!
5//! This crate supports `no_std` environments with an allocator:
6//!
7//! ```toml
8//! # With std (default)
9//! drizzle-core = "0.1"
10//!
11//! # no_std with allocator
12//! drizzle-core = { version = "0.1", default-features = false, features = ["alloc"] }
13//! ```
14
15#![cfg_attr(not(feature = "std"), no_std)]
16
17#[cfg(feature = "alloc")]
18extern crate alloc;
19
20// Prelude for std/alloc compatibility
21pub(crate) mod prelude {
22    // Re-export alloc types for std builds too (they're the same underlying types)
23    #[cfg(feature = "std")]
24    pub use std::{
25        borrow::Cow,
26        boxed::Box,
27        collections::HashMap,
28        format,
29        string::{String, ToString},
30        vec::Vec,
31    };
32
33    #[cfg(all(feature = "alloc", not(feature = "std")))]
34    pub use alloc::{
35        borrow::Cow,
36        boxed::Box,
37        format,
38        string::{String, ToString},
39        vec::Vec,
40    };
41
42    // For no_std, use hashbrown instead of std::collections::HashMap
43    #[cfg(all(feature = "alloc", not(feature = "std")))]
44    pub use hashbrown::HashMap;
45}
46
47pub mod builder;
48pub mod dialect;
49pub mod error;
50pub mod expr;
51pub mod helpers;
52pub mod join;
53pub mod param;
54pub mod placeholder;
55pub mod prepared;
56#[cfg(feature = "profiling")]
57pub mod profiling;
58pub mod schema;
59pub mod sql;
60pub mod traits;
61pub mod types;
62
63// Re-export key types and traits
64pub use builder::{BuilderInit, ExecutableState, OrderByClause};
65pub use dialect::{Dialect, DialectExt};
66pub use join::{Join, JoinType};
67pub use param::{OwnedParam, Param, ParamBind};
68pub use placeholder::*;
69pub use schema::OrderBy;
70pub use sql::{OwnedSQL, OwnedSQLChunk, SQL, SQLChunk, Token};
71pub use traits::*;
72
73// =============================================================================
74// Helper Macros - Used by proc macros for code generation
75// =============================================================================
76
77/// Generates TryFrom implementations for multiple integer types that delegate to i64.
78///
79/// Used by the SQLiteEnum derive macro to avoid repetitive code.
80///
81/// # Example
82/// ```ignore
83/// impl_try_from_int!(MyEnum => isize, usize, i32, u32, i16, u16, i8, u8);
84/// ```
85#[macro_export]
86macro_rules! impl_try_from_int {
87    ($name:ty => $($int_type:ty),+ $(,)?) => {
88        $(
89            impl TryFrom<$int_type> for $name {
90                type Error = $crate::error::DrizzleError;
91
92                fn try_from(value: $int_type) -> ::core::result::Result<Self, Self::Error> {
93                    Self::try_from(value as i64)
94                }
95            }
96        )+
97    };
98}