Skip to main content

Key

Struct Key 

Source
pub struct Key { /* private fields */ }
Expand description

A key identifying a Value.

Implementations§

Source§

impl Key

Source

pub const fn from_static(b: &'static [u8]) -> Key

Create a new Key from static bytes without copying.

Source

pub const fn from_static_str(b: &'static str) -> Key

Create a new Key from a &'static str without copying.

Source

pub fn as_str(&self) -> Option<&str>

Read the key as a str slice if it can be parsed as a UTF8 string.

Source

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

Read the key as a byte slice.

Source

pub fn inner(&self) -> &Bytes

Read the inner Bytes struct.

Source

pub fn as_str_lossy(&self) -> Cow<'_, str>

Read the key as a lossy UTF8 string with String::from_utf8_lossy.

Source

pub fn into_string(self) -> Option<String>

Convert the key to a UTF8 string, if possible.

Source

pub fn into_bytes(self) -> Bytes

Read the inner bytes making up the key.

Source

pub fn as_bytes_str(&self) -> Option<StrInner<Bytes>>

Parse and return the key as a Str without copying the inner contents.

Source

pub fn cluster_hash(&self) -> u16

Hash the key to find the associated cluster hash slot.

Source

pub fn cluster_owner<C>(&self, client: &C) -> Option<Server>
where C: ClientLike,

Read the host:port of the cluster node that owns the key if the client is clustered and the cluster state is known.

Source

pub fn take(&mut self) -> Bytes

Replace this key with an empty byte array, returning the bytes from the original key.

Source

pub fn convert<K>(self) -> Result<K, Error>
where K: FromKey,

Attempt to convert the key to any type that implements FromKey.

See the Value::convert documentation for more information.

Trait Implementations§

Source§

impl Clone for Key

Source§

fn clone(&self) -> Key

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 Debug for Key

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a [u8]> for Key

Source§

fn from(b: &'a [u8]) -> Key

Converts to this type from the input type.
Source§

impl From<&Key> for Key

Source§

fn from(k: &Key) -> Key

Converts to this type from the input type.
Source§

impl From<&StrInner<Bytes>> for Key

Source§

fn from(s: &StrInner<Bytes>) -> Key

Converts to this type from the input type.
Source§

impl From<&String> for Key

Source§

fn from(s: &String) -> Key

Converts to this type from the input type.
Source§

impl From<&str> for Key

Source§

fn from(s: &str) -> Key

Converts to this type from the input type.
Source§

impl From<Box<[u8]>> for Key

Source§

fn from(b: Box<[u8]>) -> Key

Converts to this type from the input type.
Source§

impl From<Bytes> for Key

Source§

fn from(b: Bytes) -> Key

Converts to this type from the input type.
Source§

impl From<StrInner<Bytes>> for Key

Source§

fn from(s: StrInner<Bytes>) -> Key

Converts to this type from the input type.
Source§

impl From<String> for Key

Source§

fn from(s: String) -> Key

Converts to this type from the input type.
Source§

impl From<bool> for Key

Source§

fn from(b: bool) -> Key

Converts to this type from the input type.
Source§

impl From<f32> for Key

Source§

fn from(val: f32) -> Key

Converts to this type from the input type.
Source§

impl From<f64> for Key

Source§

fn from(val: f64) -> Key

Converts to this type from the input type.
Source§

impl From<i128> for Key

Source§

fn from(val: i128) -> Key

Converts to this type from the input type.
Source§

impl From<i16> for Key

Source§

fn from(val: i16) -> Key

Converts to this type from the input type.
Source§

impl From<i32> for Key

Source§

fn from(val: i32) -> Key

Converts to this type from the input type.
Source§

impl From<i64> for Key

Source§

fn from(val: i64) -> Key

Converts to this type from the input type.
Source§

impl From<i8> for Key

Source§

fn from(val: i8) -> Key

Converts to this type from the input type.
Source§

impl From<isize> for Key

Source§

fn from(val: isize) -> Key

Converts to this type from the input type.
Source§

impl From<u128> for Key

Source§

fn from(val: u128) -> Key

Converts to this type from the input type.
Source§

impl From<u16> for Key

Source§

fn from(val: u16) -> Key

Converts to this type from the input type.
Source§

impl From<u32> for Key

Source§

fn from(val: u32) -> Key

Converts to this type from the input type.
Source§

impl From<u64> for Key

Source§

fn from(val: u64) -> Key

Converts to this type from the input type.
Source§

impl From<u8> for Key

Source§

fn from(val: u8) -> Key

Converts to this type from the input type.
Source§

impl From<usize> for Key

Source§

fn from(val: usize) -> Key

Converts to this type from the input type.
Source§

impl FromKey for Key

Source§

impl FromValue for Key

Source§

impl Hash for Key

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Key

Source§

fn cmp(&self, other: &Key) -> 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 Key

Source§

fn eq(&self, other: &Key) -> 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 Key

Source§

fn partial_cmp(&self, other: &Key) -> 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 TryFrom<Value> for Key

Source§

type Error = Error

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

fn try_from(value: Value) -> Result<Key, <Key as TryFrom<Value>>::Error>

Performs the conversion.
Source§

impl Eq for Key

Source§

impl StructuralPartialEq for Key

Auto Trait Implementations§

§

impl !Freeze for Key

§

impl RefUnwindSafe for Key

§

impl Send for Key

§

impl Sync for Key

§

impl Unpin for Key

§

impl UnsafeUnpin for Key

§

impl UnwindSafe for Key

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> IntoEither for T

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V