pub struct VectorKey { /* private fields */ }Expand description
A variable-size key type that stores data on the heap.
VectorKey is a heap-allocated key type that can store keys of any size.
It’s ideal for scenarios where key sizes are not known at compile time
or when keys can be very large.
§Features
- Variable size: Can store keys of any length
- Heap allocated: Uses heap memory for storage
- Null termination: Automatically adds null termination for string keys
- Efficient: Uses
Box<[u8]>for minimal memory overhead
§Examples
use rart::keys::vector_key::VectorKey;
// Create from string (adds null terminator)
let key1: VectorKey = "hello world".into();
// Create from numeric types
let key2: VectorKey = 42u64.into();
// Create from long strings
let long_string = "a".repeat(1000);
let key3: VectorKey = long_string.into();§When to Use
Use VectorKey when:
- Key sizes are unknown at compile time
- Keys can be very large (> 32 bytes)
- You need maximum flexibility
Use ArrayKey when:
- Key sizes are bounded and known
- You want optimal performance
- Keys are relatively small (< 32 bytes)
Implementations§
Trait Implementations§
Source§impl From<VectorKey> for VectorPartial
impl From<VectorKey> for VectorPartial
Source§impl KeyTrait for VectorKey
impl KeyTrait for VectorKey
Source§const MAXIMUM_SIZE: Option<usize> = None
const MAXIMUM_SIZE: Option<usize> = None
Maximum size of this key type, if any.
Source§type PartialType = VectorPartial
type PartialType = VectorPartial
The partial type associated with this key type.
Source§fn extend_from_partial(&self, partial: &Self::PartialType) -> Self
fn extend_from_partial(&self, partial: &Self::PartialType) -> Self
Extend this key with bytes from a partial.
Source§fn new_from_slice(data: &[u8]) -> Self
fn new_from_slice(data: &[u8]) -> Self
Create a new key from a byte slice.
Source§fn length_at(&self, at_depth: usize) -> usize
fn length_at(&self, at_depth: usize) -> usize
Get the length of the key starting from the specified depth.
Source§fn to_partial(&self, at_depth: usize) -> VectorPartial
fn to_partial(&self, at_depth: usize) -> VectorPartial
Convert part of this key to a partial starting from the specified depth.
Source§fn matches_slice(&self, slice: &[u8]) -> bool
fn matches_slice(&self, slice: &[u8]) -> bool
Check if this key matches the given byte slice exactly.
Source§fn new_from_partial(partial: &Self::PartialType) -> Self
fn new_from_partial(partial: &Self::PartialType) -> Self
Create a new key from a partial.
Source§impl Ord for VectorKey
impl Ord for VectorKey
Source§impl PartialOrd for VectorKey
impl PartialOrd for VectorKey
impl Eq for VectorKey
impl StructuralPartialEq for VectorKey
Auto Trait Implementations§
impl Freeze for VectorKey
impl RefUnwindSafe for VectorKey
impl Send for VectorKey
impl Sync for VectorKey
impl Unpin for VectorKey
impl UnsafeUnpin for VectorKey
impl UnwindSafe for VectorKey
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