pub struct KeyBuilder { /* private fields */ }Expand description
Builder for segment-safe composite keys.
Segments are escaped and terminated so component boundaries remain unambiguous while preserving byte ordering within each segment.
§Example
use prolly::{prefix_range, KeyBuilder};
let prefix = KeyBuilder::new()
.push_str("conversation")
.push_str("c42")
.finish();
let (start, end) = prefix_range(&prefix);
let message_key = KeyBuilder::from_prefix(prefix)
.push_u64(7)
.finish();
assert!(message_key >= start);
assert!(end.as_ref().map_or(true, |end| message_key < *end));Implementations§
Source§impl KeyBuilder
impl KeyBuilder
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create an empty key builder with reserved capacity.
Sourcepub fn from_prefix(prefix: impl Into<Vec<u8>>) -> Self
pub fn from_prefix(prefix: impl Into<Vec<u8>>) -> Self
Continue building from an existing prefix.
Sourcepub fn push_raw(self, bytes: impl AsRef<[u8]>) -> Self
pub fn push_raw(self, bytes: impl AsRef<[u8]>) -> Self
Append raw bytes without segment escaping.
Prefer KeyBuilder::push_segment for tuple-like components.
Sourcepub fn push_segment(self, segment: impl AsRef<[u8]>) -> Self
pub fn push_segment(self, segment: impl AsRef<[u8]>) -> Self
Append one escaped byte segment.
Sourcepub fn push_timestamp_millis(self, value: u64) -> Self
pub fn push_timestamp_millis(self, value: u64) -> Self
Append one Unix-millisecond timestamp segment.
Trait Implementations§
Source§impl Clone for KeyBuilder
impl Clone for KeyBuilder
Source§fn clone(&self) -> KeyBuilder
fn clone(&self) -> KeyBuilder
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for KeyBuilder
impl Debug for KeyBuilder
Source§impl Default for KeyBuilder
impl Default for KeyBuilder
Source§fn default() -> KeyBuilder
fn default() -> KeyBuilder
Returns the “default value” for a type. Read more
impl Eq for KeyBuilder
Source§impl PartialEq for KeyBuilder
impl PartialEq for KeyBuilder
impl StructuralPartialEq for KeyBuilder
Auto Trait Implementations§
impl Freeze for KeyBuilder
impl RefUnwindSafe for KeyBuilder
impl Send for KeyBuilder
impl Sync for KeyBuilder
impl Unpin for KeyBuilder
impl UnsafeUnpin for KeyBuilder
impl UnwindSafe for KeyBuilder
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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