Skip to main content

Resp3Value

Enum Resp3Value 

Source
pub enum Resp3Value {
Show 15 variants SimpleString(String), SimpleError(String), Number(i64), BlobString(String), Array(Vec<Self>), Null, Boolean(bool), Double(f64), BigNumber(String), BlobError(String), VerbatimString { encoding: String, data: String, }, Map(HashMap<String, Self>), Set(HashSet<Self>), Attribute { attrs: HashMap<String, Self>, data: Box<Self>, }, Push(Vec<Self>),
}
Expand description

RESP3 protocol data types

Variants§

§

SimpleString(String)

Simple string: +OK\r\n

§

SimpleError(String)

Simple error: -ERR message\r\n

§

Number(i64)

Number (integer): :123\r\n

§

BlobString(String)

Blob string: $5\r\nhello\r\n

§

Array(Vec<Self>)

Array: *3\r\n$3\r\nfoo\r\n$3\r\nbar\r\n$3\r\nbaz\r\n

§

Null

Null: _\r\n

§

Boolean(bool)

Boolean: #t\r\n or #f\r\n

§

Double(f64)

Double: ,1.23\r\n

§

BigNumber(String)

Big number: (3492890328409238509324850943850943825024385\r\n

§

BlobError(String)

Blob error: !21\r\nSYNTAX invalid syntax\r\n

§

VerbatimString

Verbatim string: =15\r\ntxt:Some string\r\n

Fields

§encoding: String

The encoding type (e.g., “txt”, “mkd”)

§data: String

The actual string data

§

Map(HashMap<String, Self>)

Map: %2\r\n+first\r\n:1\r\n+second\r\n:2\r\n

§

Set(HashSet<Self>)

Set: ~3\r\n+orange\r\n+apple\r\n+one\r\n

§

Attribute

Attribute: |1\r\n+ttl\r\n:3600\r\n+key\r\n+value\r\n

Fields

§attrs: HashMap<String, Self>

The attribute key-value pairs

§data: Box<Self>

The actual data with attributes attached

§

Push(Vec<Self>)

Push: >4\r\n+pubsub\r\n+message\r\n+channel\r\n+hello\r\n

Implementations§

Source§

impl Resp3Value

Source

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.

Source

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.

Source

pub fn as_float(&self) -> RedisResult<f64>

Convert to a float if possible

§Errors

Returns an error if the value cannot be converted to a float.

Source

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.

Source

pub const fn is_null(&self) -> bool

Check if the value is null

Source

pub const fn type_name(&self) -> &'static str

Get the type name of the value

Trait Implementations§

Source§

impl Clone for Resp3Value

Source§

fn clone(&self) -> Resp3Value

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Resp3Value

Source§

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

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

impl Eq for Resp3Value

Source§

impl From<Resp3Value> for RespValue

Convert RESP3 value to RESP2 value for backward compatibility

Source§

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

Source§

fn from(value: RespValue) -> Self

Converts to this type from the input type.
Source§

impl Hash for Resp3Value

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 PartialEq for Resp3Value

Source§

fn eq(&self, other: &Resp3Value) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Resp3Value

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
Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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.
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