pub struct KeyBuilder { /* private fields */ }Expand description
Streams typed logical fields into a canonical cache key.
Integer methods use little-endian fixed-width encoding. Variable-width
strings and bytes are type-tagged and length-prefixed. There is deliberately
no usize method because cache identities must not depend on target width.
§Examples
use lance_core::cache::{CacheKeySchema, CacheNamespace, KeyBuilder};
let namespace = CacheNamespace::root().child("dataset");
let mut builder = KeyBuilder::new(
namespace,
"example.Page",
CacheKeySchema::new("example.page-key", 1),
);
builder.write_u32(7);
builder.write_str("values");
let key = builder.finish();
assert_eq!(key.as_bytes().len(), 16);Implementations§
Source§impl KeyBuilder
impl KeyBuilder
Sourcepub fn new(
namespace: CacheNamespace,
stable_type_id: &'static str,
schema: CacheKeySchema,
) -> Self
pub fn new( namespace: CacheNamespace, stable_type_id: &'static str, schema: CacheKeySchema, ) -> Self
Start a key in a namespace with a stable value type and key schema.
Sourcepub fn write_bool(&mut self, value: bool)
pub fn write_bool(&mut self, value: bool)
Append a tagged boolean.
Sourcepub fn write_bytes(&mut self, value: &[u8])
pub fn write_bytes(&mut self, value: &[u8])
Append tagged, length-prefixed bytes.
Sourcepub fn write_fixed_bytes<const N: usize>(&mut self, value: &[u8; N])
pub fn write_fixed_bytes<const N: usize>(&mut self, value: &[u8; N])
Append a tagged fixed-size byte array, including its length.
Sourcepub fn write_none(&mut self)
pub fn write_none(&mut self)
Append the canonical marker for an absent optional value.
Sourcepub fn write_some(&mut self)
pub fn write_some(&mut self)
Append the canonical marker for a present optional value.
Sourcepub fn write_variant(&mut self, variant: u32)
pub fn write_variant(&mut self, variant: u32)
Append a tagged enum variant ordinal.
Sourcepub fn write_sequence_len(&mut self, len: u64)
pub fn write_sequence_len(&mut self, len: u64)
Append the length of a following sequence.
Sourcepub fn finish(self) -> InternalCacheKey
pub fn finish(self) -> InternalCacheKey
Finalize and return the canonical 128-bit key.
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§
impl<T> Allocation for T
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