pub enum DataType {
Show 19 variants
Integer(IntegerDataType),
Decimal(DecimalDataType),
Float(FloatDataType),
Boolean(BooleanDataType),
Char(CharDataType),
VarChar(VarCharDataType),
Text(TextDataType),
Binary(BinaryDataType),
VarBinary(VarBinaryDataType),
Date(DateDataType),
Time(TimeDataType),
Timestamp(TimestampDataType),
TimestampTz(TimestampTzDataType),
DateTime(DateTimeDataType),
Interval(IntervalDataType),
Uuid(UuidDataType),
Json(JsonDataType),
Array(ArrayDataType),
Map(MapDataType),
}Expand description
Unified data type enumeration covering all supported types across databases.
This is the primary type system for Razeri. Every field, column, and
parameter in a design document is typed using DataType. The enum captures
enough metadata to generate correct DDL for all 8 dialect plugins while
remaining abstract over platform-specific implementation details.
§Type Categories
| Category | Variants | Example |
|---|---|---|
| Numeric | Integer, Decimal, Float | INT, DECIMAL(19,4), DOUBLE |
| Boolean | Boolean | BOOLEAN, BIT |
| String | Char, VarChar, Text | VARCHAR(100), TEXT |
| Binary | Binary, VarBinary | BYTEA, VARBINARY |
| Date/Time | Date, Time, Timestamp, TimestampTz, DateTime, Interval | DATE, TIMESTAMP |
| Special | Uuid, Json | UUID, JSONB |
| Collection | Array, Map | INTEGER[], MAP<TEXT,INT> |
§Design Principles
- Abstract over database-specific implementations —
DataTypecaptures enough metadata to generate correct DDL for each target, but does not embed platform-specific syntax. - Preserve precision metadata — Decimal types carry precision and scale; string types carry length constraints; timestamp types carry fractional seconds precision.
- Support intersection of capabilities — All types in the enum can be
rendered by all 8 dialect plugins, even if some platforms emulate a type
(e.g., JSON stored as
NVARCHAR(MAX)in SQL Server).
§Usage
use razeri_plugin_contract::DataType;
// Convenience constructors for common types
let id = DataType::bigint();
let name = DataType::varchar(255);
let price = DataType::decimal(19, 4);
let created = DataType::timestamp();
// JSON with binary storage (JSONB in PostgreSQL, VARIANT in Snowflake)
let data = DataType::json();§Cross-Database Mapping
Each variant maps to platform-specific types as documented in the variant
definitions. Dialect plugins resolve the final SQL type string during
rendering; the rendering traits live in this crate’s renderer module.
Variants§
Integer(IntegerDataType)
Signed/unsigned integer (1, 2, 4, or 8 bytes).
Decimal(DecimalDataType)
Exact numeric with fixed precision and scale.
Float(FloatDataType)
Approximate floating-point (4 or 8 bytes).
Boolean(BooleanDataType)
Boolean (true/false).
Char(CharDataType)
Fixed-length character string.
VarChar(VarCharDataType)
Variable-length character string.
Text(TextDataType)
Unbounded text type.
Binary(BinaryDataType)
Fixed-length binary data.
VarBinary(VarBinaryDataType)
Variable-length binary data.
Date(DateDataType)
Date only (year, month, day).
Time(TimeDataType)
Time only (hour, minute, second, optional timezone).
Timestamp(TimestampDataType)
Timestamp without timezone.
TimestampTz(TimestampTzDataType)
Timestamp with timezone.
DateTime(DateTimeDataType)
Combined date and time (legacy).
Interval(IntervalDataType)
Interval/duration.
Uuid(UuidDataType)
UUID/GUID.
Json(JsonDataType)
JSON/semi-structured data.
Array(ArrayDataType)
Array of elements.
Map(MapDataType)
Map/dictionary with key-value pairs.
Implementations§
Source§impl DataType
impl DataType
Sourcepub fn tinyint() -> Self
pub fn tinyint() -> Self
Creates a 1-byte signed integer (TINYINT / SMALLINT / Int8).
§Example
use razeri_plugin_contract::DataType;
let ty = DataType::tinyint();
assert!(matches!(ty, DataType::Integer(_)));Sourcepub fn smallint() -> Self
pub fn smallint() -> Self
Creates a 2-byte signed integer (SMALLINT / Int16).
§Example
use razeri_plugin_contract::DataType;
let ty = DataType::smallint();
assert!(matches!(ty, DataType::Integer(_)));Sourcepub fn int() -> Self
pub fn int() -> Self
Creates a 4-byte signed integer (INT / INTEGER / Int32).
§Example
use razeri_plugin_contract::DataType;
let id = DataType::int();
assert!(matches!(id, DataType::Integer(_)));Sourcepub fn bigint() -> Self
pub fn bigint() -> Self
Creates an 8-byte signed integer (BIGINT / Int64).
§Example
use razeri_plugin_contract::DataType;
let id = DataType::bigint();
assert!(matches!(id, DataType::Integer(_)));Sourcepub fn decimal(precision: u8, scale: u8) -> Self
pub fn decimal(precision: u8, scale: u8) -> Self
Creates a DECIMAL(precision, scale) type.
§Panics
Panics if precision is 0 or exceeds 38, or if scale > precision.
§Example
use razeri_plugin_contract::DataType;
let price = DataType::decimal(19, 4);
assert!(matches!(price, DataType::Decimal(_)));use razeri_plugin_contract::DataType;
let _ = DataType::decimal(0, 0); // panics: precision must be 1-38Sourcepub fn float() -> Self
pub fn float() -> Self
Creates a single-precision float (REAL / FLOAT4).
§Example
use razeri_plugin_contract::DataType;
let ty = DataType::float();
assert!(matches!(ty, DataType::Float(_)));Sourcepub fn double() -> Self
pub fn double() -> Self
Creates a double-precision float (DOUBLE PRECISION / DOUBLE).
§Example
use razeri_plugin_contract::DataType;
let ty = DataType::double();
assert!(matches!(ty, DataType::Float(_)));Sourcepub fn boolean() -> Self
pub fn boolean() -> Self
Creates a boolean type (BOOLEAN / BIT).
§Example
use razeri_plugin_contract::DataType;
let ty = DataType::boolean();
assert!(matches!(ty, DataType::Boolean(_)));Sourcepub fn varchar(max_length: u32) -> Self
pub fn varchar(max_length: u32) -> Self
Creates a VARCHAR(max_length) type.
§Example
use razeri_plugin_contract::DataType;
let name = DataType::varchar(255);
assert!(matches!(name, DataType::VarChar(_)));Sourcepub fn text() -> Self
pub fn text() -> Self
Creates an unbounded text type (TEXT / VARCHAR(MAX) / STRING).
§Example
use razeri_plugin_contract::DataType;
let ty = DataType::text();
assert!(matches!(ty, DataType::Text(_)));Sourcepub fn date() -> Self
pub fn date() -> Self
Creates a date-only type (DATE).
§Example
use razeri_plugin_contract::DataType;
let ty = DataType::date();
assert!(matches!(ty, DataType::Date(_)));Sourcepub fn timestamp() -> Self
pub fn timestamp() -> Self
Creates a timestamp without timezone (TIMESTAMP).
§Example
use razeri_plugin_contract::DataType;
let created = DataType::timestamp();
assert!(matches!(created, DataType::Timestamp(_)));Sourcepub fn timestamp_tz() -> Self
pub fn timestamp_tz() -> Self
Creates a timestamp with timezone (TIMESTAMPTZ / DATETIMEOFFSET).
§Example
use razeri_plugin_contract::DataType;
let created_tz = DataType::timestamp_tz();
assert!(matches!(created_tz, DataType::TimestampTz(_)));Sourcepub fn uuid() -> Self
pub fn uuid() -> Self
Creates a UUID type (UUID / UNIQUEIDENTIFIER).
§Example
use razeri_plugin_contract::DataType;
let ty = DataType::uuid();
assert!(matches!(ty, DataType::Uuid(_)));