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    Time = 11,
16}
17
18#[allow(dead_code)] // Names/affinities are consumed by the build, payloads by Rust.
19pub struct Descriptor {
20    pub kind: Kind,
21    pub name: &'static str,
22    pub affinity: u8,
23    pub tag: u8,
24    pub payload_size: usize,
25}
26
27pub const TYPES: &[Descriptor] = &[
28    Descriptor {
29        kind: Kind::Decimal,
30        name: "DECIMAL",
31        affinity: 0x47,
32        tag: b'd',
33        payload_size: 0,
34    },
35    Descriptor {
36        kind: Kind::Uuid,
37        name: "UUID",
38        affinity: 0x48,
39        tag: b'u',
40        payload_size: 16,
41    },
42    Descriptor {
43        kind: Kind::Instant,
44        name: "INSTANT",
45        affinity: 0x49,
46        tag: b'i',
47        payload_size: 12,
48    },
49    Descriptor {
50        kind: Kind::Date,
51        name: "DATE",
52        affinity: 0x4a,
53        tag: b'a',
54        payload_size: 4,
55    },
56    Descriptor {
57        kind: Kind::DateTime,
58        name: "DATETIME",
59        affinity: 0x4b,
60        tag: b't',
61        payload_size: 12,
62    },
63    Descriptor {
64        kind: Kind::Interval,
65        name: "INTERVAL",
66        affinity: 0x4c,
67        tag: b'v',
68        payload_size: 16,
69    },
70    Descriptor {
71        kind: Kind::Uint8,
72        name: "UINT8",
73        affinity: 0x4d,
74        tag: b'C',
75        payload_size: 1,
76    },
77    Descriptor {
78        kind: Kind::Uint16,
79        name: "UINT16",
80        affinity: 0x4e,
81        tag: b'S',
82        payload_size: 2,
83    },
84    Descriptor {
85        kind: Kind::Uint32,
86        name: "UINT32",
87        affinity: 0x4f,
88        tag: b'L',
89        payload_size: 4,
90    },
91    Descriptor {
92        kind: Kind::Uint64,
93        name: "UINT64",
94        affinity: 0x60,
95        tag: b'Q',
96        payload_size: 8,
97    },
98    Descriptor {
99        kind: Kind::Time,
100        name: "TIME",
101        affinity: 0x61,
102        tag: b'h',
103        payload_size: 8,
104    },
105];