Skip to content

Commit 370506e

Browse files
authored
Merge pull request #1257 from muzarski/cql-value-non-exhaustive
value: mark CqlValue as non_exhaustive
2 parents c24db77 + 7810380 commit 370506e

File tree

11 files changed

+349
-414
lines changed

11 files changed

+349
-414
lines changed

Cargo.lock.msrv

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scylla-cql/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ secrecy-08 = { package = "secrecy", version = "0.8", optional = true }
1919
snap = "1.0"
2020
uuid = "1.0"
2121
thiserror = "2.0.6"
22+
itertools = "0.14.0"
2223
num-bigint-03 = { package = "num-bigint", version = "0.3", optional = true }
2324
num-bigint-04 = { package = "num-bigint", version = "0.4", optional = true }
2425
bigdecimal-04 = { package = "bigdecimal", version = "0.4", optional = true }
25-
chrono-04 = { package = "chrono", version = "0.4.32", default-features = false, optional = true }
26+
chrono-04 = { package = "chrono", version = "0.4.32", default-features = false, features = ["alloc"] }
2627
lz4_flex = { version = "0.11.1" }
2728
async-trait = "0.1.57"
2829
serde = { version = "1.0", features = ["derive"], optional = true }
@@ -45,7 +46,7 @@ harness = false
4546
[features]
4647
secrecy-08 = ["dep:secrecy-08"]
4748
time-03 = ["dep:time-03"]
48-
chrono-04 = ["dep:chrono-04"]
49+
chrono-04 = []
4950
num-bigint-03 = ["dep:num-bigint-03"]
5051
num-bigint-04 = ["dep:num-bigint-04"]
5152
bigdecimal-04 = ["dep:bigdecimal-04"]

scylla-cql/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
pub(crate) mod pretty;
2+
13
pub mod frame;
24
#[macro_use]
35
pub mod macros {

scylla-cql/src/pretty.rs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
use std::fmt::{Display, LowerHex, UpperHex};
2+
3+
pub(crate) struct HexBytes<'a>(pub(crate) &'a [u8]);
4+
5+
impl LowerHex for HexBytes<'_> {
6+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7+
for b in self.0 {
8+
write!(f, "{:02x}", b)?;
9+
}
10+
Ok(())
11+
}
12+
}
13+
14+
impl UpperHex for HexBytes<'_> {
15+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16+
for b in self.0 {
17+
write!(f, "{:02X}", b)?;
18+
}
19+
Ok(())
20+
}
21+
}
22+
23+
pub(crate) struct CqlStringLiteralDisplayer<'a>(pub(crate) &'a str);
24+
25+
impl Display for CqlStringLiteralDisplayer<'_> {
26+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27+
// CQL string literals use single quotes. The only character that
28+
// needs escaping is singular quote, and escaping is done by repeating
29+
// the quote character.
30+
f.write_str("'")?;
31+
let mut first = true;
32+
for part in self.0.split('\'') {
33+
if first {
34+
first = false;
35+
} else {
36+
f.write_str("''")?;
37+
}
38+
f.write_str(part)?;
39+
}
40+
f.write_str("'")?;
41+
Ok(())
42+
}
43+
}
44+
45+
pub(crate) struct PairDisplayer<K, V>(pub(crate) K, pub(crate) V);
46+
47+
impl<K, V> Display for PairDisplayer<K, V>
48+
where
49+
K: Display,
50+
V: Display,
51+
{
52+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
53+
write!(f, "{}:{}", self.0, self.1)
54+
}
55+
}
56+
57+
pub(crate) struct MaybeNullDisplayer<T>(pub(crate) Option<T>);
58+
59+
impl<T> Display for MaybeNullDisplayer<T>
60+
where
61+
T: Display,
62+
{
63+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
64+
match &self.0 {
65+
None => write!(f, "null")?,
66+
Some(v) => write!(f, "{}", v)?,
67+
}
68+
Ok(())
69+
}
70+
}

0 commit comments

Comments
 (0)