pub struct StringIndex { /* private fields */ }Expand description
Secondary index mapping variable-length string keys to fixed 32-byte DonaDbX keys.
Implementations§
Source§impl StringIndex
impl StringIndex
Sourcepub fn with_persistence(path: &Path) -> Result<Self>
pub fn with_persistence(path: &Path) -> Result<Self>
Create a string index with persistence to a manifest file.
Sourcepub fn save_to_disk(&self) -> Result<()>
pub fn save_to_disk(&self) -> Result<()>
Save the string index to disk.
Sourcepub fn insert(&self, string_key: &[u8], fixed_key: [u8; 32])
pub fn insert(&self, string_key: &[u8], fixed_key: [u8; 32])
Insert or update a string key → 32-byte key mapping.
Sourcepub fn get(&self, string_key: &[u8]) -> Option<[u8; 32]>
pub fn get(&self, string_key: &[u8]) -> Option<[u8; 32]>
Get the fixed 32-byte key for a string key.
Sourcepub fn scan_prefix(&self, prefix: &[u8]) -> Vec<(Vec<u8>, [u8; 32])>
pub fn scan_prefix(&self, prefix: &[u8]) -> Vec<(Vec<u8>, [u8; 32])>
Scan for all keys matching a prefix, return (string_key, fixed_key) pairs.
This collects from all shards in parallel and sorts the results lexicographically. Fast for small result sets (typical blockchain queries return 10-1000 entries).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for StringIndex
impl !UnwindSafe for StringIndex
impl Freeze for StringIndex
impl Send for StringIndex
impl Sync for StringIndex
impl Unpin for StringIndex
impl UnsafeUnpin for StringIndex
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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