From 0426f92ac032f03b8a4c86acec00b53c093a82d5 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 25 Oct 2024 18:25:06 +0000 Subject: [PATCH] unify database record separator constants Signed-off-by: Jason Volk --- src/database/de.rs | 3 +-- src/database/mod.rs | 2 +- src/database/ser.rs | 5 ++++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/database/de.rs b/src/database/de.rs index e5fdf7cb..0e074fdb 100644 --- a/src/database/de.rs +++ b/src/database/de.rs @@ -41,8 +41,7 @@ pub struct Ignore; pub struct IgnoreAll; impl<'de> Deserializer<'de> { - /// Record separator; an intentionally invalid-utf8 byte. - const SEP: u8 = b'\xFF'; + const SEP: u8 = crate::ser::SEP; /// Determine if the input was fully consumed and error if bytes remaining. /// This is intended for debug assertions; not optimized for parsing logic. diff --git a/src/database/mod.rs b/src/database/mod.rs index 6d3b2079..dcd66a1e 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -29,7 +29,7 @@ pub use self::{ handle::Handle, keyval::{KeyVal, Slice}, map::Map, - ser::{serialize, serialize_to_array, serialize_to_vec, Interfix, Json, Separator}, + ser::{serialize, serialize_to_array, serialize_to_vec, Interfix, Json, Separator, SEP}, }; conduit::mod_ctor! {} diff --git a/src/database/ser.rs b/src/database/ser.rs index 742f1e34..0cc5c886 100644 --- a/src/database/ser.rs +++ b/src/database/ser.rs @@ -69,8 +69,11 @@ pub struct Interfix; #[derive(Debug, Serialize)] pub struct Separator; +/// Record separator; an intentionally invalid-utf8 byte. +pub const SEP: u8 = b'\xFF'; + impl Serializer<'_, W> { - const SEP: &'static [u8] = b"\xFF"; + const SEP: &'static [u8] = &[SEP]; fn tuple_start(&mut self) { debug_assert!(!self.sep, "Tuple start with separator set");