Skip to main content

VectorKey

Struct VectorKey 

Source
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§

Source§

impl VectorKey

Source

pub fn new_from_string(s: &String) -> Self

Source

pub fn new_from_str(s: &str) -> Self

Source

pub fn new_from_vec(data: Vec<u8>) -> Self

Source

pub fn to_be_u64(&self) -> u64

Trait Implementations§

Source§

impl AsRef<[u8]> for VectorKey

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for VectorKey

Source§

fn clone(&self) -> VectorKey

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl From<&String> for VectorKey

Source§

fn from(data: &String) -> Self

Converts to this type from the input type.
Source§

impl From<&i128> for VectorKey

Source§

fn from(val: &i128) -> Self

Converts to this type from the input type.
Source§

impl From<&i16> for VectorKey

Source§

fn from(val: &i16) -> Self

Converts to this type from the input type.
Source§

impl From<&i32> for VectorKey

Source§

fn from(val: &i32) -> Self

Converts to this type from the input type.
Source§

impl From<&i64> for VectorKey

Source§

fn from(val: &i64) -> Self

Converts to this type from the input type.
Source§

impl From<&isize> for VectorKey

Source§

fn from(val: &isize) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for VectorKey

Source§

fn from(data: &str) -> Self

Converts to this type from the input type.
Source§

impl From<&u128> for VectorKey

Source§

fn from(data: &u128) -> Self

Converts to this type from the input type.
Source§

impl From<&u16> for VectorKey

Source§

fn from(data: &u16) -> Self

Converts to this type from the input type.
Source§

impl From<&u32> for VectorKey

Source§

fn from(data: &u32) -> Self

Converts to this type from the input type.
Source§

impl From<&u64> for VectorKey

Source§

fn from(data: &u64) -> Self

Converts to this type from the input type.
Source§

impl From<&u8> for VectorKey

Source§

fn from(data: &u8) -> Self

Converts to this type from the input type.
Source§

impl From<&usize> for VectorKey

Source§

fn from(data: &usize) -> Self

Converts to this type from the input type.
Source§

impl From<String> for VectorKey

Source§

fn from(data: String) -> Self

Converts to this type from the input type.
Source§

impl From<VectorKey> for VectorPartial

Source§

fn from(value: VectorKey) -> Self

Converts to this type from the input type.
Source§

impl From<i128> for VectorKey

Source§

fn from(val: i128) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for VectorKey

Source§

fn from(val: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for VectorKey

Source§

fn from(val: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for VectorKey

Source§

fn from(val: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for VectorKey

Source§

fn from(val: i8) -> Self

Converts to this type from the input type.
Source§

impl From<isize> for VectorKey

Source§

fn from(val: isize) -> Self

Converts to this type from the input type.
Source§

impl From<u128> for VectorKey

Source§

fn from(data: u128) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for VectorKey

Source§

fn from(data: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for VectorKey

Source§

fn from(data: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for VectorKey

Source§

fn from(data: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for VectorKey

Source§

fn from(data: u8) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for VectorKey

Source§

fn from(data: usize) -> Self

Converts to this type from the input type.
Source§

impl KeyTrait for VectorKey

Source§

const MAXIMUM_SIZE: Option<usize> = None

Maximum size of this key type, if any.
Source§

type PartialType = VectorPartial

The partial type associated with this key type.
Source§

fn extend_from_partial(&self, partial: &Self::PartialType) -> Self

Extend this key with bytes from a partial.
Source§

fn truncate(&self, at_depth: usize) -> Self

Truncate this key to the specified depth.
Source§

fn new_from_slice(data: &[u8]) -> Self

Create a new key from a byte slice.
Source§

fn at(&self, pos: usize) -> u8

Get the byte at the specified position.
Source§

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

Convert part of this key to a partial starting from the specified depth.
Source§

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

Create a new key from a partial.
Source§

impl Ord for VectorKey

Source§

fn cmp(&self, other: &VectorKey) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for VectorKey

Source§

fn eq(&self, other: &VectorKey) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for VectorKey

Source§

fn partial_cmp(&self, other: &VectorKey) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for VectorKey

Source§

impl StructuralPartialEq for VectorKey

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.