Struct rsmq_async::RedisBytes
source · pub struct RedisBytes(/* private fields */);
Expand description
Internal value representing the redis bytes.
It implements TryFrom
String
and Vec<u8>
and From String
, &str
, Vec<u8>
and &[u8]
to
itself.
You can add your custom TryFrom and From implementation in order to make automatically transform you value to yours when executing a command in redis.
As example, the current String implementation:
ⓘ
use std::convert::TryFrom;
use rsmq_async::RedisBytes;
impl TryFrom<RedisBytes> for String {
type Error = Vec<u8>;
fn try_from(bytes: RedisBytes) -> Result<Self, Self::Error> {
String::from_utf8(bytes.0).map_err(|e| e.into_bytes())
}
}
Implementations§
source§impl RedisBytes
impl RedisBytes
sourcepub fn into_bytes(self) -> Vec<u8>
pub fn into_bytes(self) -> Vec<u8>
Consumes the value and returns the raw bytes as Vec<u8>
Trait Implementations§
source§impl Debug for RedisBytes
impl Debug for RedisBytes
source§impl From<&[u8]> for RedisBytes
impl From<&[u8]> for RedisBytes
source§fn from(t: &[u8]) -> RedisBytes
fn from(t: &[u8]) -> RedisBytes
Converts to this type from the input type.
source§impl From<&str> for RedisBytes
impl From<&str> for RedisBytes
source§fn from(t: &str) -> RedisBytes
fn from(t: &str) -> RedisBytes
Converts to this type from the input type.
source§impl From<String> for RedisBytes
impl From<String> for RedisBytes
source§fn from(t: String) -> RedisBytes
fn from(t: String) -> RedisBytes
Converts to this type from the input type.
source§impl TryFrom<RedisBytes> for String
impl TryFrom<RedisBytes> for String
Auto Trait Implementations§
impl Freeze for RedisBytes
impl RefUnwindSafe for RedisBytes
impl Send for RedisBytes
impl Sync for RedisBytes
impl Unpin for RedisBytes
impl UnwindSafe for RedisBytes
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
Mutably borrows from an owned value. Read more