pub struct KeySerializer<'a, B: Buffer> { /* private fields */ }Expand description
Serializes keys sequentially into binary format suitable for lexicographical comparisons.
The key layout contains:
- Sequences of 255-byte chunks, each prefixed with a 1-byte length.
- If a serialized key is <= 254 bytes, it is represented as a single chunk with a 1-byte length.
- If exactly a multiple of 255 bytes, it is terminated by a 0-length chunk.
Implementations§
Source§impl<'a, B: Buffer> KeySerializer<'a, B>
impl<'a, B: Buffer> KeySerializer<'a, B>
Sourcepub fn new(buffer: &'a mut B, base: Option<u64>) -> Self
pub fn new(buffer: &'a mut B, base: Option<u64>) -> Self
Creates a new KeySerializer attached to a persistent storage buffer.
Sourcepub fn write_varint(&mut self, v: u64)
pub fn write_varint(&mut self, v: u64)
Writes an order-preserving varint-encoded 64-bit payload to the buffer without base delta encoding.
Sourcepub fn write_u64(&mut self, v: u64)
pub fn write_u64(&mut self, v: u64)
Writes an order-preserving varint-encoded 64-bit payload to the buffer.
If a delta base was provided and this is the first item written, it writes the delta
v - base. Otherwise, writes v as an order-preserving varint.
Sourcepub fn write_bytes(&mut self, bytes: &[u8])
pub fn write_bytes(&mut self, bytes: &[u8])
Writes a raw byte slice into the serialization stream. Non-terminal fields are assumed to fit within the initial chunk.
Sourcepub fn write_last(self, bytes: &[u8]) -> KeySerializerFinalized
pub fn write_last(self, bytes: &[u8]) -> KeySerializerFinalized
Writes trailing variable-length dynamic bytes to the serialization buffer, crossing chunk boundaries as needed, then immediately finalizes the key.
Sourcepub fn finalize(self) -> KeySerializerFinalized
pub fn finalize(self) -> KeySerializerFinalized
Resolves chunk lengths and finalizes the key serialization.
Trait Implementations§
Source§impl<B: Buffer> From<KeySerializer<'_, B>> for KeySerializerFinalized
impl<B: Buffer> From<KeySerializer<'_, B>> for KeySerializerFinalized
Source§fn from(serializer: KeySerializer<'_, B>) -> Self
fn from(serializer: KeySerializer<'_, B>) -> Self
Source§impl<'a, B: Buffer + 'a> MergeSerializerOutput<KeySerializer<'a, B>> for KeySerializer<'a, B>
impl<'a, B: Buffer + 'a> MergeSerializerOutput<KeySerializer<'a, B>> for KeySerializer<'a, B>
type Output = KeySerializer<'a, B>
Source§impl<'a, B: Buffer + 'a> MergeSerializerOutput<KeySerializer<'a, B>> for KeySerializerFinalized
impl<'a, B: Buffer + 'a> MergeSerializerOutput<KeySerializer<'a, B>> for KeySerializerFinalized
Source§impl<'a, B: Buffer + 'a> MergeSerializerOutput<KeySerializerFinalized> for KeySerializer<'a, B>
impl<'a, B: Buffer + 'a> MergeSerializerOutput<KeySerializerFinalized> for KeySerializer<'a, B>
Auto Trait Implementations§
impl<'a, B> !UnwindSafe for KeySerializer<'a, B>
impl<'a, B> Freeze for KeySerializer<'a, B>
impl<'a, B> RefUnwindSafe for KeySerializer<'a, B>where
B: RefUnwindSafe,
impl<'a, B> Send for KeySerializer<'a, B>
impl<'a, B> Sync for KeySerializer<'a, B>where
B: Sync,
impl<'a, B> Unpin for KeySerializer<'a, B>
impl<'a, B> UnsafeUnpin for KeySerializer<'a, B>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more