sdf_metadata/metadata/metadata/
arrow_column_kind.rs

1use wit_encoder::Type;
2
3use crate::wit::metadata::ArrowColumnKind;
4
5impl ArrowColumnKind {
6    pub fn rust_variant_str(&self) -> &'static str {
7        match self {
8            Self::U8 => "U8",
9            Self::U16 => "U16",
10            Self::U32 => "U32",
11            Self::U64 => "U64",
12            Self::S8 => "I8",
13            Self::S16 => "I16",
14            Self::S32 => "I32",
15            Self::S64 => "I64",
16            Self::Float32 => "Float32",
17            Self::Float64 => "Float64",
18            Self::Bool => "Bool",
19            Self::String => "String",
20            Self::Timestamp => "Timestamp",
21        }
22    }
23
24    pub fn ty(&self) -> &'static str {
25        match self {
26            Self::U8 => "u8",
27            Self::U16 => "u16",
28            Self::U32 => "u32",
29            Self::U64 => "u64",
30            Self::S8 => "s8",
31            Self::S16 => "s16",
32            Self::S32 => "s32",
33            Self::S64 => "s64",
34            Self::Float32 => "f32",
35            Self::Float64 => "f64",
36            Self::Bool => "bool",
37            Self::String => "string",
38            Self::Timestamp => "s64",
39        }
40    }
41
42    pub fn wit_type(&self) -> Type {
43        match self {
44            Self::U8 => Type::U8,
45            Self::U16 => Type::U16,
46            Self::U32 => Type::U32,
47            Self::U64 => Type::U64,
48            Self::S8 => Type::S8,
49            Self::S16 => Type::S16,
50            Self::S32 => Type::S32,
51            Self::S64 => Type::S64,
52            Self::Float32 => Type::F32,
53            Self::Float64 => Type::F64,
54            Self::Bool => Type::Bool,
55            Self::String => Type::String,
56            Self::Timestamp => Type::S64,
57        }
58    }
59}