pub struct StoreKeyPrefix { /* private fields */ }Expand description
A client-side namespace layered over raw Store keys.
The prefix prepends a fixed byte string to each physical Store key and
stores the caller’s logical key in the remaining bytes. QMDB, SQL, and
other higher-level instances continue to build their own logical keys as
before; a prefixed StoreClient maps those keys on the wire and maps
returned keys back before callers see them.
Implementations§
Source§impl StoreKeyPrefix
impl StoreKeyPrefix
pub fn new(prefix: impl Into<Bytes>) -> Result<Self, StoreKeyPrefixError>
Sourcepub const fn identity() -> Self
pub const fn identity() -> Self
The zero-width identity prefix: maps every logical key to itself, so encode/decode/range/match are all no-ops and keys pass through un-namespaced.
Sourcepub fn matches(&self, key: &[u8]) -> bool
pub fn matches(&self, key: &[u8]) -> bool
True when key starts with this prefix. The identity prefix matches
every key.
Sourcepub fn max_logical_key_len(&self) -> usize
pub fn max_logical_key_len(&self) -> usize
Maximum logical key bytes available under this prefix.
Sourcepub fn encode_key(&self, key: &Key) -> Result<Key, StoreKeyPrefixError>
pub fn encode_key(&self, key: &Key) -> Result<Key, StoreKeyPrefixError>
Encode a logical key into the physical Store keyspace. The identity
prefix returns a refcount-only clone of key.
Sourcepub fn decode_key(&self, key: &Key) -> Result<Key, StoreKeyPrefixError>
pub fn decode_key(&self, key: &Key) -> Result<Key, StoreKeyPrefixError>
Decode a physical Store key back into the logical keyspace as a
zero-copy slice of key’s backing storage.
Sourcepub fn encode_range(
&self,
start: &Key,
end: &Key,
) -> Result<(Key, Key), StoreKeyPrefixError>
pub fn encode_range( &self, start: &Key, end: &Key, ) -> Result<(Key, Key), StoreKeyPrefixError>
Encode an inclusive logical range into the physical Store keyspace.
Empty end means unbounded in the logical keyspace and is narrowed to
this prefix’s physical upper bound. Long logical upper bounds are
clamped to the maximum logical key length representable under this
prefix; this keeps scans over full-width prefix bounds (whose upper
bound is intentionally MAX_KEY_LEN bytes) working.
Trait Implementations§
Source§impl Clone for StoreKeyPrefix
impl Clone for StoreKeyPrefix
Source§fn clone(&self) -> StoreKeyPrefix
fn clone(&self) -> StoreKeyPrefix
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StoreKeyPrefix
impl Debug for StoreKeyPrefix
impl Eq for StoreKeyPrefix
Source§impl Hash for StoreKeyPrefix
impl Hash for StoreKeyPrefix
Source§impl PartialEq for StoreKeyPrefix
impl PartialEq for StoreKeyPrefix
impl StructuralPartialEq for StoreKeyPrefix
Auto Trait Implementations§
impl !Freeze for StoreKeyPrefix
impl RefUnwindSafe for StoreKeyPrefix
impl Send for StoreKeyPrefix
impl Sync for StoreKeyPrefix
impl Unpin for StoreKeyPrefix
impl UnsafeUnpin for StoreKeyPrefix
impl UnwindSafe for StoreKeyPrefix
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.