rorm_sql/value.rs
1use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc};
2use time::{Date, OffsetDateTime, PrimitiveDateTime, Time};
3use uuid::Uuid;
4
5/// This enum represents a [Null](Value::Null)'s type
6#[derive(Copy, Clone, Debug, PartialEq, Eq)]
7pub enum NullType {
8 /// String representation
9 String,
10 /// Choice representation
11 Choice,
12 /// i64 representation
13 I64,
14 /// i32 representation
15 I32,
16 /// i16 representation
17 I16,
18 /// Bool representation
19 Bool,
20 /// f64 representation
21 F64,
22 /// f32 representation
23 F32,
24 /// binary representation
25 Binary,
26 /// Naive Time representation
27 ChronoNaiveTime,
28 /// Naive Date representation
29 ChronoNaiveDate,
30 /// Naive DateTime representation
31 ChronoNaiveDateTime,
32 /// Chrono timezone aware date time representation
33 ChronoDateTime,
34 /// time's date representation
35 TimeDate,
36 /// time's time representation
37 TimeTime,
38 /// time's offset datetime representation
39 TimeOffsetDateTime,
40 /// time's primitive datetime representation
41 TimePrimitiveDateTime,
42 /// Uuid representation
43 Uuid,
44 /// Uuid in hyphenated representation
45 UuidHyphenated,
46 /// Uuid in simple text representation
47 UuidSimple,
48 /// serde_json's Value representation
49 JsonValue,
50 /// Mac address representation
51 #[cfg(feature = "postgres-only")]
52 MacAddress,
53 /// IP network presentation
54 #[cfg(feature = "postgres-only")]
55 IpNetwork,
56 /// Bit vec representation
57 #[cfg(feature = "postgres-only")]
58 BitVec,
59}
60
61/**
62This enum represents a value
63 */
64#[derive(Copy, Clone, Debug, PartialEq)]
65pub enum Value<'a> {
66 /// null representation
67 Null(NullType),
68 /// Representation of an identifier, e.g. a column.
69 /// This variant will not be escaped, so do not
70 /// pass unchecked data to it.
71 Ident(&'a str),
72 /// Representation of a column name with
73 /// an optional table name
74 Column {
75 /// Name of the table
76 table_name: Option<&'a str>,
77 /// Name of the column
78 column_name: &'a str,
79 },
80 /// Representation of choices
81 Choice(&'a str),
82 /// String representation
83 String(&'a str),
84 /// i64 representation
85 I64(i64),
86 /// i32 representation
87 I32(i32),
88 /// i16 representation
89 I16(i16),
90 /// Bool representation
91 Bool(bool),
92 /// f64 representation
93 F64(f64),
94 /// f32 representation
95 F32(f32),
96 /// binary representation
97 Binary(&'a [u8]),
98 /// chrono's Naive Time representation
99 ChronoNaiveTime(NaiveTime),
100 /// chrono's Naive Date representation
101 ChronoNaiveDate(NaiveDate),
102 /// chrono's Naive DateTime representation
103 ChronoNaiveDateTime(NaiveDateTime),
104 /// chrono's Timezone aware datetime
105 ChronoDateTime(DateTime<Utc>),
106 /// time's date representation
107 TimeDate(Date),
108 /// time's time representation
109 TimeTime(Time),
110 /// time's offset datetime representation
111 TimeOffsetDateTime(OffsetDateTime),
112 /// time's primitive datetime representation
113 TimePrimitiveDateTime(PrimitiveDateTime),
114 /// Uuid representation
115 Uuid(Uuid),
116 /// Uuid in hyphenated representation
117 UuidHyphenated(Uuid),
118 /// Uuid in simple text representation
119 UuidSimple(Uuid),
120 /// serde_json's Value representation
121 JsonValue(&'a serde_json::Value),
122 /// Mac address representation
123 #[cfg(feature = "postgres-only")]
124 MacAddress(mac_address::MacAddress),
125 /// IP network presentation
126 #[cfg(feature = "postgres-only")]
127 IpNetwork(ipnetwork::IpNetwork),
128 /// Bit vec representation
129 #[cfg(feature = "postgres-only")]
130 BitVec(&'a bit_vec::BitVec),
131}