Struct fred::types::RedisKey

source ·
pub struct RedisKey { /* private fields */ }
Expand description

A key in Redis.

Implementations§

source§

impl RedisKey

source

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

Create a new RedisKey from static bytes without copying.

source

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

Create a new RedisKey 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<Str>

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, RedisError>
where K: FromRedisKey,

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

See the RedisValue::convert documentation for more information.

Trait Implementations§

source§

impl Clone for RedisKey

source§

fn clone(&self) -> RedisKey

Returns a copy 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 RedisKey

source§

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

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

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

source§

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

Converts to this type from the input type.
source§

impl From<&RedisKey> for RedisKey

source§

fn from(k: &RedisKey) -> RedisKey

Converts to this type from the input type.
source§

impl From<&StrInner<Bytes>> for RedisKey

source§

fn from(s: &Str) -> Self

Converts to this type from the input type.
source§

impl From<&String> for RedisKey

source§

fn from(s: &String) -> Self

Converts to this type from the input type.
source§

impl From<&str> for RedisKey

source§

fn from(s: &str) -> Self

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

impl From<Bytes> for RedisKey

source§

fn from(b: Bytes) -> Self

Converts to this type from the input type.
source§

impl From<RedisKey> for RedisValue

source§

fn from(d: RedisKey) -> Self

Converts to this type from the input type.
source§

impl From<StrInner<Bytes>> for RedisKey

source§

fn from(s: Str) -> Self

Converts to this type from the input type.
source§

impl From<String> for RedisKey

source§

fn from(s: String) -> Self

Converts to this type from the input type.
source§

impl From<bool> for RedisKey

source§

fn from(b: bool) -> Self

Converts to this type from the input type.
source§

impl From<f32> for RedisKey

source§

fn from(val: f32) -> Self

Converts to this type from the input type.
source§

impl From<f64> for RedisKey

source§

fn from(val: f64) -> Self

Converts to this type from the input type.
source§

impl From<i128> for RedisKey

source§

fn from(val: i128) -> Self

Converts to this type from the input type.
source§

impl From<i16> for RedisKey

source§

fn from(val: i16) -> Self

Converts to this type from the input type.
source§

impl From<i32> for RedisKey

source§

fn from(val: i32) -> Self

Converts to this type from the input type.
source§

impl From<i64> for RedisKey

source§

fn from(val: i64) -> Self

Converts to this type from the input type.
source§

impl From<i8> for RedisKey

source§

fn from(val: i8) -> Self

Converts to this type from the input type.
source§

impl From<isize> for RedisKey

source§

fn from(val: isize) -> Self

Converts to this type from the input type.
source§

impl From<u128> for RedisKey

source§

fn from(val: u128) -> Self

Converts to this type from the input type.
source§

impl From<u16> for RedisKey

source§

fn from(val: u16) -> Self

Converts to this type from the input type.
source§

impl From<u32> for RedisKey

source§

fn from(val: u32) -> Self

Converts to this type from the input type.
source§

impl From<u64> for RedisKey

source§

fn from(val: u64) -> Self

Converts to this type from the input type.
source§

impl From<u8> for RedisKey

source§

fn from(val: u8) -> Self

Converts to this type from the input type.
source§

impl From<usize> for RedisKey

source§

fn from(val: usize) -> Self

Converts to this type from the input type.
source§

impl FromRedis for RedisKey

source§

impl FromRedisKey for RedisKey

source§

impl Hash for RedisKey

source§

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

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 RedisKey

source§

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

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

impl PartialEq for RedisKey

source§

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

source§

fn partial_cmp(&self, other: &RedisKey) -> 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<RedisValue> for RedisKey

source§

type Error = RedisError

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

fn try_from(value: RedisValue) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Eq for RedisKey

source§

impl StructuralPartialEq for RedisKey

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
§

impl<T> CallHasher for T
where T: Hash + ?Sized,

§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

source§

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

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

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

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more