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
39
40
41
42
43
44
45
use super::data_type::DataType;
use odbc_sys::WChar;
use std::char::{decode_utf16, DecodeUtf16Error};
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Nullable {
Unknown,
Nullable,
NoNulls,
}
impl Default for Nullable {
fn default() -> Self {
Nullable::Unknown
}
}
#[derive(Clone, Debug, Eq, PartialEq, Default)]
pub struct ColumnDescription {
pub name: Vec<WChar>,
pub data_type: DataType,
pub nullable: Nullable,
}
impl ColumnDescription {
pub fn name_to_string(&self) -> Result<String, DecodeUtf16Error> {
decode_utf16(self.name.iter().copied()).collect()
}
pub fn could_be_nullable(&self) -> bool {
match self.nullable {
Nullable::Nullable | Nullable::Unknown => true,
Nullable::NoNulls => false,
}
}
}