Skip to main content

libsqlite3_sys/
native_types.rs

1//! One registry shared by the SQLite build and native value implementation.
2#[derive(Clone, Copy, Debug, PartialEq, Eq)]
3#[repr(u8)]
4pub enum Kind {
5    Decimal = 1,
6    Uuid = 2,
7    Instant = 3,
8    Date = 4,
9    DateTime = 5,
10    Interval = 6,
11    Uint8 = 7,
12    Uint16 = 8,
13    Uint32 = 9,
14    Uint64 = 10,
15}
16
17#[allow(dead_code)] // Names/affinities are consumed by the build, payloads by Rust.
18pub struct Descriptor {
19    pub kind: Kind,
20    pub name: &'static str,
21    pub affinity: u8,
22    pub tag: u8,
23    pub payload_size: usize,
24}
25
26pub const TYPES: &[Descriptor] = &[
27    Descriptor {
28        kind: Kind::Decimal,
29        name: "DECIMAL",
30        affinity: 0x47,
31        tag: b'd',
32        payload_size: 0,
33    },
34    Descriptor {
35        kind: Kind::Uuid,
36        name: "UUID",
37        affinity: 0x48,
38        tag: b'u',
39        payload_size: 16,
40    },
41    Descriptor {
42        kind: Kind::Instant,
43        name: "INSTANT",
44        affinity: 0x49,
45        tag: b'i',
46        payload_size: 12,
47    },
48    Descriptor {
49        kind: Kind::Date,
50        name: "DATE",
51        affinity: 0x4a,
52        tag: b'a',
53        payload_size: 4,
54    },
55    Descriptor {
56        kind: Kind::DateTime,
57        name: "DATETIME",
58        affinity: 0x4b,
59        tag: b't',
60        payload_size: 12,
61    },
62    Descriptor {
63        kind: Kind::Interval,
64        name: "INTERVAL",
65        affinity: 0x4c,
66        tag: b'v',
67        payload_size: 16,
68    },
69    Descriptor {
70        kind: Kind::Uint8,
71        name: "UINT8",
72        affinity: 0x4d,
73        tag: b'C',
74        payload_size: 1,
75    },
76    Descriptor {
77        kind: Kind::Uint16,
78        name: "UINT16",
79        affinity: 0x4e,
80        tag: b'S',
81        payload_size: 2,
82    },
83    Descriptor {
84        kind: Kind::Uint32,
85        name: "UINT32",
86        affinity: 0x4f,
87        tag: b'L',
88        payload_size: 4,
89    },
90    Descriptor {
91        kind: Kind::Uint64,
92        name: "UINT64",
93        affinity: 0x60,
94        tag: b'Q',
95        payload_size: 8,
96    },
97];