pub enum Value {
Nil,
Int(i64),
Data(Vec<u8>),
Bulk(Vec<Value>),
Status(String),
Okay,
}
Expand description
Internal low-level redis value enum.
Variants§
Nil
A nil response from the server.
Int(i64)
An integer response. Note that there are a few situations in which redis actually returns a string for an integer which is why this library generally treats integers and strings the same for all numeric responses.
Data(Vec<u8>)
An arbitary binary data.
Bulk(Vec<Value>)
A bulk response of more data. This is generally used by redis to express nested structures.
Status(String)
A status response.
Okay
A status response which represents the string “OK”.
Implementations§
source§impl Value
impl Value
Values are generally not used directly unless you are using the
more low level functionality in the library. For the most part
this is hidden with the help of the FromRedisValue
trait.
While on the redis protocol there is an error type this is already separated at an early point so the value only holds the remaining types.
sourcepub fn looks_like_cursor(&self) -> bool
pub fn looks_like_cursor(&self) -> bool
Checks if the return value looks like it fulfils the cursor protocol. That means the result is a bulk item of length two with the first one being a cursor and the second a bulk response.
sourcepub fn as_sequence(&self) -> Option<&[Value]>
pub fn as_sequence(&self) -> Option<&[Value]>
Returns an &[Value]
if self
is compatible with a sequence type
sourcepub fn into_sequence(self) -> Result<Vec<Value>, Value>
pub fn into_sequence(self) -> Result<Vec<Value>, Value>
Returns a Vec<Value>
if self
is compatible with a sequence type,
otherwise returns Err(self)
.
sourcepub fn as_map_iter(&self) -> Option<MapIter<'_>>
pub fn as_map_iter(&self) -> Option<MapIter<'_>>
Returns an iterator of (&Value, &Value)
if self
is compatible with a map type
sourcepub fn into_map_iter(self) -> Result<OwnedMapIter, Value>
pub fn into_map_iter(self) -> Result<OwnedMapIter, Value>
Returns an iterator of (Value, Value)
if self
is compatible with a map type.
If not, returns Err(self)
.
Trait Implementations§
source§impl FromRedisValue for Value
impl FromRedisValue for Value
source§fn from_redis_value(v: &Value) -> RedisResult<Value>
fn from_redis_value(v: &Value) -> RedisResult<Value>
Value
this attempts to convert it into the given
destination type. If that fails because it’s not compatible an
appropriate error is generated.source§fn from_owned_redis_value(v: Value) -> RedisResult<Self>
fn from_owned_redis_value(v: Value) -> RedisResult<Self>
Value
this attempts to convert it into the given
destination type. If that fails because it’s not compatible an
appropriate error is generated.source§fn from_redis_values(items: &[Value]) -> RedisResult<Vec<Self>>
fn from_redis_values(items: &[Value]) -> RedisResult<Vec<Self>>
from_redis_value
but constructs a vector of objects
from another vector of values. This primarily exists internally
to customize the behavior for vectors of tuples.source§fn from_owned_redis_values(items: Vec<Value>) -> RedisResult<Vec<Self>>
fn from_owned_redis_values(items: Vec<Value>) -> RedisResult<Vec<Self>>
from_redis_values
, but takes a Vec<Value>
instead
of a &[Value]
.source§fn from_owned_byte_vec(_vec: Vec<u8>) -> RedisResult<Vec<Self>>
fn from_owned_byte_vec(_vec: Vec<u8>) -> RedisResult<Vec<Self>>
impl Eq for Value
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
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
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
)