KeyExt

Trait KeyExt 

Source
pub trait KeyExt {
Show 13 methods // Required method fn as_bytes(&self) -> &[u8] ; // Provided methods fn as_ptr(&self) -> *const u8 { ... } fn as_key_ref(&self) -> KeyRef<'_> { ... } fn parse_key(&self) -> &[u8] { ... } fn parse_timestamp(&self) -> u64 { ... } fn same_key(&self, other: impl KeyExt) -> bool { ... } fn compare_key(&self, other: impl KeyExt) -> Ordering { ... } fn has_prefix(&self, prefix: impl KeyExt) -> bool { ... } fn has_suffix(&self, suffix: impl KeyExt) -> bool { ... } fn longest_prefix(&self, other: impl KeyExt) -> &[u8] { ... } fn longest_suffix(&self, other: impl KeyExt) -> &[u8] { ... } fn longest_prefix_lossy(&self, other: impl KeyExt) -> Cow<'_, [u8]> { ... } fn longest_suffix_lossy(&self, other: impl KeyExt) -> Cow<'_, [u8]> { ... }
}
Expand description

Extensions for Key

Required Methods§

Source

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

Returns the underlying slice of key (with timestamp data).

Provided Methods§

Source

fn as_ptr(&self) -> *const u8

Returns raw pointer of the underlying byte slice

Source

fn as_key_ref(&self) -> KeyRef<'_>

Returns a KeyRef.

Source

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

Parses the actual key from the key bytes.

Source

fn parse_timestamp(&self) -> u64

Parses the timestamp from the key bytes.

§Panics

If the length of key less than 8.

Source

fn same_key(&self, other: impl KeyExt) -> bool

Checks for key equality ignoring the version timestamp.

Source

fn compare_key(&self, other: impl KeyExt) -> Ordering

Checks the key without timestamp and checks the timestamp if keyNoTs is same. a would be sorted higher than aa if we use bytes.compare All keys should have timestamp.

Source

fn has_prefix(&self, prefix: impl KeyExt) -> bool

Returns whether the slice self begins with prefix.

Source

fn has_suffix(&self, suffix: impl KeyExt) -> bool

Returns whether the slice self ends with suffix.

Source

fn longest_prefix(&self, other: impl KeyExt) -> &[u8]

Finds the longest shared prefix

Source

fn longest_suffix(&self, other: impl KeyExt) -> &[u8]

Finds the longest shared suffix

Source

fn longest_prefix_lossy(&self, other: impl KeyExt) -> Cow<'_, [u8]>

Finds the longest shared prefix, return a Cow<’_, u8>.

Source

fn longest_suffix_lossy(&self, other: impl KeyExt) -> Cow<'_, [u8]>

Finds the longest shared suffix, return a Cow<’_, u8>.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl KeyExt for str

Source§

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

Source§

impl KeyExt for Box<[u8]>

Source§

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

Source§

impl KeyExt for String

Source§

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

Source§

impl KeyExt for Vec<u8>

Source§

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

Source§

impl KeyExt for [u8]

Source§

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

Source§

impl<'a> KeyExt for &'a str

Source§

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

Source§

impl<'a> KeyExt for &'a Box<[u8]>

Source§

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

Source§

impl<'a> KeyExt for &'a String

Source§

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

Source§

impl<'a> KeyExt for &'a Vec<u8>

Source§

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

Source§

impl<'a> KeyExt for &'a [u8]

Source§

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

Source§

impl<'a> KeyExt for &'a mut str

Source§

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

Source§

impl<'a> KeyExt for &'a mut Box<[u8]>

Source§

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

Source§

impl<'a> KeyExt for &'a mut String

Source§

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

Source§

impl<'a> KeyExt for &'a mut Vec<u8>

Source§

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

Source§

impl<'a> KeyExt for &'a mut [u8]

Source§

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

Source§

impl<'a, const N: usize> KeyExt for &'a [u8; N]

Source§

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

Source§

impl<'a, const N: usize> KeyExt for &'a mut [u8; N]

Source§

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

Source§

impl<const N: usize> KeyExt for [u8; N]

Source§

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

Implementors§

Source§

impl KeyExt for &KeyRef<'_>

Source§

impl KeyExt for &mut KeyRef<'_>

Source§

impl KeyExt for Bytes

Source§

impl KeyExt for BytesMut

Source§

impl KeyExt for RawKeyPointer

Source§

impl KeyExt for Key

Source§

impl KeyExt for KeyMut

Source§

impl KeyExt for KeyRef<'_>

Source§

impl<'a> KeyExt for &'a Bytes

Source§

impl<'a> KeyExt for &'a BytesMut

Source§

impl<'a> KeyExt for &'a Key

Source§

impl<'a> KeyExt for &'a KeyMut

Source§

impl<'a> KeyExt for &'a mut Bytes

Source§

impl<'a> KeyExt for &'a mut BytesMut

Source§

impl<'a> KeyExt for &'a mut Key

Source§

impl<'a> KeyExt for &'a mut KeyMut