Skip to content

Commit 457b77a

Browse files
committed
fix: improve binary compatibility check
1 parent 2883ea2 commit 457b77a

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

questdb-rs/src/ingress/buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ impl Buffer {
10561056
self.write_column_key(name)?;
10571057
value.serialize(
10581058
&mut self.output,
1059-
self.protocol_version == ProtocolVersion::V2,
1059+
self.protocol_version.supports_binary_encoding(),
10601060
)?;
10611061
Ok(self)
10621062
}

questdb-rs/src/ingress/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,23 @@ pub enum ProtocolVersion {
9191
V2 = 2,
9292
}
9393

94+
impl ProtocolVersion {
95+
/// Returns `true` if this protocol version supports binary-encoded column values.
96+
///
97+
/// # Examples
98+
///
99+
/// ```
100+
/// use questdb::ingress::ProtocolVersion;
101+
///
102+
/// assert_eq!(ProtocolVersion::V1.supports_binary_encoding(), false);
103+
/// assert_eq!(ProtocolVersion::V2.supports_binary_encoding(), true);
104+
/// ```
105+
#[inline]
106+
pub fn supports_binary_encoding(self) -> bool {
107+
self != ProtocolVersion::V1
108+
}
109+
}
110+
94111
impl Display for ProtocolVersion {
95112
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
96113
match self {

0 commit comments

Comments
 (0)