reifydb_core/interface/catalog/
column.rs1use std::ops::Deref;
5
6use reifydb_type::value::{constraint::TypeConstraint, dictionary::DictionaryId};
7use serde::{Deserialize, Serialize};
8
9use crate::interface::catalog::{id::ColumnId, policy::ColumnPolicy};
10
11#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12pub struct ColumnDef {
13 pub id: ColumnId,
14 pub name: String,
15 pub constraint: TypeConstraint,
16 pub policies: Vec<ColumnPolicy>,
17 pub index: ColumnIndex,
18 pub auto_increment: bool,
19 pub dictionary_id: Option<DictionaryId>,
20}
21
22#[repr(transparent)]
23#[derive(Debug, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash, Serialize, Deserialize)]
24pub struct ColumnIndex(pub u8);
25
26impl Deref for ColumnIndex {
27 type Target = u8;
28
29 fn deref(&self) -> &Self::Target {
30 &self.0
31 }
32}
33
34impl PartialEq<u8> for ColumnIndex {
35 fn eq(&self, other: &u8) -> bool {
36 self.0.eq(other)
37 }
38}
39
40impl From<ColumnIndex> for u8 {
41 fn from(value: ColumnIndex) -> Self {
42 value.0
43 }
44}