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
46
47
48
49
use crate::mysql::protocol::Type;
use crate::mysql::MySql;
use crate::types::HasTypeMetadata;

mod bool;
mod bytes;
mod float;
mod int;
mod str;
mod uint;

#[cfg(feature = "chrono")]
mod chrono;

#[derive(Default, Debug)]
pub struct MySqlTypeMetadata {
    pub(crate) r#type: Type,
    pub(crate) is_unsigned: bool,
}

impl MySqlTypeMetadata {
    pub(crate) fn new(r#type: Type) -> Self {
        Self {
            r#type,
            is_unsigned: false,
        }
    }

    pub(crate) fn unsigned(r#type: Type) -> Self {
        Self {
            r#type,
            is_unsigned: true,
        }
    }
}

impl HasTypeMetadata for MySql {
    type TypeMetadata = MySqlTypeMetadata;

    type TableId = Box<str>;

    type TypeId = u8;
}

impl PartialEq<u8> for MySqlTypeMetadata {
    fn eq(&self, other: &u8) -> bool {
        &self.r#type.0 == other
    }
}