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 #[deprecated(note = "Is this still used?")]
72 Ident(&'a str),
73 /// Representation of a column name with
74 /// an optional table name
75 Column {
76 /// Name of the table
77 table_name: Option<&'a str>,
78 /// Name of the column
79 column_name: &'a str,
80 },
81 /// Representation of choices
82 Choice(&'a str),
83 /// String representation
84 String(&'a str),
85 /// i64 representation
86 I64(i64),
87 /// i32 representation
88 I32(i32),
89 /// i16 representation
90 I16(i16),
91 /// Bool representation
92 Bool(bool),
93 /// f64 representation
94 F64(f64),
95 /// f32 representation
96 F32(f32),
97 /// binary representation
98 Binary(&'a [u8]),
99 /// chrono's Naive Time representation
100 ChronoNaiveTime(NaiveTime),
101 /// chrono's Naive Date representation
102 ChronoNaiveDate(NaiveDate),
103 /// chrono's Naive DateTime representation
104 ChronoNaiveDateTime(NaiveDateTime),
105 /// chrono's Timezone aware datetime
106 ChronoDateTime(DateTime<Utc>),
107 /// time's date representation
108 TimeDate(Date),
109 /// time's time representation
110 TimeTime(Time),
111 /// time's offset datetime representation
112 TimeOffsetDateTime(OffsetDateTime),
113 /// time's primitive datetime representation
114 TimePrimitiveDateTime(PrimitiveDateTime),
115 /// Uuid representation
116 Uuid(Uuid),
117 /// Uuid in hyphenated representation
118 #[deprecated(note = "Was this ever used?")]
119 UuidHyphenated(Uuid),
120 /// Uuid in simple text representation
121 #[deprecated(note = "Was this ever used?")]
122 UuidSimple(Uuid),
123 /// serde_json's Value representation
124 JsonValue(&'a serde_json::Value),
125
126 /// Mac address representation
127 #[cfg(feature = "postgres-only")]
128 MacAddress(mac_address::MacAddress),
129 /// IP network presentation
130 #[cfg(feature = "postgres-only")]
131 IpNetwork(ipnetwork::IpNetwork),
132 /// Bit vec representation
133 #[cfg(feature = "postgres-only")]
134 BitVec(&'a bit_vec::BitVec),
135
136 /// null representation
137 #[cfg(feature = "postgres-only")]
138 ArrayNull(NullType),
139 /// String representation
140 #[cfg(feature = "postgres-only")]
141 ArrayString(&'a [&'a str]),
142 /// i64 representation
143 #[cfg(feature = "postgres-only")]
144 ArrayI64(&'a [i64]),
145 /// i32 representation
146 #[cfg(feature = "postgres-only")]
147 ArrayI32(&'a [i32]),
148 /// i16 representation
149 #[cfg(feature = "postgres-only")]
150 ArrayI16(&'a [i16]),
151 /// Bool representation
152 #[cfg(feature = "postgres-only")]
153 ArrayBool(&'a [bool]),
154 /// f64 representation
155 #[cfg(feature = "postgres-only")]
156 ArrayF64(&'a [f64]),
157 /// f32 representation
158 #[cfg(feature = "postgres-only")]
159 ArrayF32(&'a [f32]),
160 /// binary representation
161 #[cfg(feature = "postgres-only")]
162 ArrayBinary(&'a [&'a [u8]]),
163 /// chrono's Naive Time representation
164 #[cfg(feature = "postgres-only")]
165 ArrayChronoNaiveTime(&'a [NaiveTime]),
166 /// chrono's Naive Date representation
167 #[cfg(feature = "postgres-only")]
168 ArrayChronoNaiveDate(&'a [NaiveDate]),
169 /// chrono's Naive DateTime representation
170 #[cfg(feature = "postgres-only")]
171 ArrayChronoNaiveDateTime(&'a [NaiveDateTime]),
172 /// chrono's Timezone aware datetime
173 #[cfg(feature = "postgres-only")]
174 ArrayChronoDateTime(&'a [DateTime<Utc>]),
175 /// time's date representation
176 #[cfg(feature = "postgres-only")]
177 ArrayTimeDate(&'a [Date]),
178 /// time's time representation
179 #[cfg(feature = "postgres-only")]
180 ArrayTimeTime(&'a [Time]),
181 /// time's offset datetime representation
182 #[cfg(feature = "postgres-only")]
183 ArrayTimeOffsetDateTime(&'a [OffsetDateTime]),
184 /// time's primitive datetime representation
185 #[cfg(feature = "postgres-only")]
186 ArrayTimePrimitiveDateTime(&'a [PrimitiveDateTime]),
187 /// Uuid representation
188 #[cfg(feature = "postgres-only")]
189 ArrayUuid(&'a [Uuid]),
190 /// serde_json's Value representation
191 #[cfg(feature = "postgres-only")]
192 ArrayJsonValue(&'a [&'a serde_json::Value]),
193
194 /// Mac address representation
195 #[cfg(feature = "postgres-only")]
196 ArrayMacAddress(&'a [mac_address::MacAddress]),
197 /// IP network presentation
198 #[cfg(feature = "postgres-only")]
199 ArrayIpNetwork(&'a [ipnetwork::IpNetwork]),
200 /// Bit vec representation
201 #[cfg(feature = "postgres-only")]
202 ArrayBitVec(&'a [&'a bit_vec::BitVec]),
203}