pub struct RedisKey { /* private fields */ }Expand description
A key in Redis.
Implementations§
source§impl RedisKey
impl RedisKey
sourcepub const fn from_static(b: &'static [u8]) -> Self
pub const fn from_static(b: &'static [u8]) -> Self
Create a new RedisKey from static bytes without copying.
sourcepub const fn from_static_str(b: &'static str) -> Self
pub const fn from_static_str(b: &'static str) -> Self
Create a new RedisKey from a &'static str without copying.
sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Read the key as a str slice if it can be parsed as a UTF8 string.
sourcepub fn as_str_lossy(&self) -> Cow<'_, str>
pub fn as_str_lossy(&self) -> Cow<'_, str>
Read the key as a lossy UTF8 string with String::from_utf8_lossy.
sourcepub fn into_string(self) -> Option<String>
pub fn into_string(self) -> Option<String>
Convert the key to a UTF8 string, if possible.
sourcepub fn into_bytes(self) -> Bytes
pub fn into_bytes(self) -> Bytes
Read the inner bytes making up the key.
sourcepub fn as_bytes_str(&self) -> Option<Str>
pub fn as_bytes_str(&self) -> Option<Str>
Parse and return the key as a Str without copying the inner contents.
sourcepub fn cluster_hash(&self) -> u16
pub fn cluster_hash(&self) -> u16
Hash the key to find the associated cluster hash slot.
sourcepub fn cluster_owner<C>(&self, client: &C) -> Option<Server>where
C: ClientLike,
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.
sourcepub fn take(&mut self) -> Bytes
pub fn take(&mut self) -> Bytes
Replace this key with an empty byte array, returning the bytes from the original key.
sourcepub fn convert<K>(self) -> Result<K, RedisError>where
K: FromRedisKey,
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 From<RedisKey> for RedisValue
impl From<RedisKey> for RedisValue
source§impl FromRedis for RedisKey
impl FromRedis for RedisKey
fn from_value(value: RedisValue) -> Result<Self, RedisError>
source§impl FromRedisKey for RedisKey
impl FromRedisKey for RedisKey
source§impl Ord for RedisKey
impl Ord for RedisKey
source§impl PartialOrd for RedisKey
impl PartialOrd for RedisKey
source§impl TryFrom<RedisValue> for RedisKey
impl TryFrom<RedisValue> for RedisKey
source§type Error = RedisError
type Error = RedisError
impl Eq for RedisKey
impl StructuralPartialEq for RedisKey
Auto Trait Implementations§
impl !Freeze for RedisKey
impl RefUnwindSafe for RedisKey
impl Send for RedisKey
impl Sync for RedisKey
impl Unpin for RedisKey
impl UnwindSafe for RedisKey
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
§impl<T> CallHasher for T
impl<T> CallHasher for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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