pub enum RespValue {
SimpleString(String),
Error(String),
Integer(i64),
BulkString(Bytes),
Null,
Array(Vec<RespValue>),
}Expand description
RESP protocol value
Variants§
SimpleString(String)
Simple string: +OK\r\n
Error(String)
Error: -ERR message\r\n
Integer(i64)
Integer: :1000\r\n
BulkString(Bytes)
Bulk string: $6\r\nfoobar\r\n
Null
Null bulk string: $-1\r\n
Array(Vec<RespValue>)
Array: *2\r\n$3\r\nfoo\r\n$3\r\nbar\r\n
Implementations§
Source§impl RespValue
impl RespValue
Sourcepub fn as_string(&self) -> RedisResult<String>
pub fn as_string(&self) -> RedisResult<String>
Convert to a string if possible
§Errors
Returns an error if the value cannot be converted to a string.
Sourcepub fn as_int(&self) -> RedisResult<i64>
pub fn as_int(&self) -> RedisResult<i64>
Convert to an integer if possible
§Errors
Returns an error if the value cannot be converted to an integer.
Sourcepub fn as_bytes(&self) -> RedisResult<Bytes>
pub fn as_bytes(&self) -> RedisResult<Bytes>
Sourcepub fn as_array(&self) -> RedisResult<Vec<Self>>
pub fn as_array(&self) -> RedisResult<Vec<Self>>
Convert to an array if possible
§Errors
Returns an error if the value cannot be converted to an array.
Sourcepub fn as_bool(&self) -> RedisResult<bool>
pub fn as_bool(&self) -> RedisResult<bool>
Convert to a boolean if possible
§Errors
Returns an error if the value cannot be converted to a boolean.
Sourcepub fn into_error(self) -> Option<String>
pub fn into_error(self) -> Option<String>
Extract error message if this is an error
Trait Implementations§
Source§impl From<Resp3Value> for RespValue
Convert RESP3 value to RESP2 value for backward compatibility
impl From<Resp3Value> for RespValue
Convert RESP3 value to RESP2 value for backward compatibility
Source§fn from(value: Resp3Value) -> Self
fn from(value: Resp3Value) -> Self
Converts to this type from the input type.
Source§impl From<RespValue> for Resp3Value
Convert RESP2 value to RESP3 value
impl From<RespValue> for Resp3Value
Convert RESP2 value to RESP3 value
impl Eq for RespValue
impl StructuralPartialEq for RespValue
Auto Trait Implementations§
impl !Freeze for RespValue
impl RefUnwindSafe for RespValue
impl Send for RespValue
impl Sync for RespValue
impl Unpin for RespValue
impl UnwindSafe for RespValue
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