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