Skip to main content

fletch_orm/
column.rs

1//! Column metadata for schema representation.
2
3/// The data type of a column.
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum ColumnType {
6    Text,
7    Integer,
8    Float,
9    Boolean,
10    Timestamp,
11    Uuid,
12    Json,
13    Blob,
14}
15
16/// A column in a database table.
17#[derive(Debug, Clone, PartialEq, Eq)]
18pub struct Column {
19    name: &'static str,
20    column_type: ColumnType,
21}
22
23impl Column {
24    /// Create a new column definition.
25    pub const fn new(name: &'static str, column_type: ColumnType) -> Self {
26        Self { name, column_type }
27    }
28
29    /// The column name.
30    pub fn name(&self) -> &str {
31        self.name
32    }
33
34    /// The column data type.
35    pub fn column_type(&self) -> ColumnType {
36        self.column_type
37    }
38}