unify database record separator constants

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-10-25 18:25:06 +00:00
parent 6808671751
commit 0426f92ac0
3 changed files with 6 additions and 4 deletions

View file

@ -41,8 +41,7 @@ pub struct Ignore;
pub struct IgnoreAll; pub struct IgnoreAll;
impl<'de> Deserializer<'de> { impl<'de> Deserializer<'de> {
/// Record separator; an intentionally invalid-utf8 byte. const SEP: u8 = crate::ser::SEP;
const SEP: u8 = b'\xFF';
/// Determine if the input was fully consumed and error if bytes remaining. /// Determine if the input was fully consumed and error if bytes remaining.
/// This is intended for debug assertions; not optimized for parsing logic. /// This is intended for debug assertions; not optimized for parsing logic.

View file

@ -29,7 +29,7 @@ pub use self::{
handle::Handle, handle::Handle,
keyval::{KeyVal, Slice}, keyval::{KeyVal, Slice},
map::Map, 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! {} conduit::mod_ctor! {}

View file

@ -69,8 +69,11 @@ pub struct Interfix;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
pub struct Separator; pub struct Separator;
/// Record separator; an intentionally invalid-utf8 byte.
pub const SEP: u8 = b'\xFF';
impl<W: Write> Serializer<'_, W> { impl<W: Write> Serializer<'_, W> {
const SEP: &'static [u8] = b"\xFF"; const SEP: &'static [u8] = &[SEP];
fn tuple_start(&mut self) { fn tuple_start(&mut self) {
debug_assert!(!self.sep, "Tuple start with separator set"); debug_assert!(!self.sep, "Tuple start with separator set");