Skip to main content

Reply

Enum Reply 

Source
pub enum Reply {
Show 15 variants Simple(Vec<u8>), Error(Vec<u8>), Int(i64), Bulk(Vec<u8>), Nil, Array(Vec<Reply>), Map(Vec<(Reply, Reply)>), Set(Vec<Reply>), Double(f64), Boolean(bool), Verbatim { fmt: [u8; 3], data: Vec<u8>, }, BigNumber(Vec<u8>), Null, Push(Vec<Reply>), BlobError(Vec<u8>),
}
Expand description

A parsed RESP reply (server → client) — the client-side counterpart of the crate’s encode_* functions (server-side encoders).

Variants prefixed with Resp3: in their doc are only ever produced by a server speaking RESP3; an HELLO 2 (or no HELLO) session sees the RESP2 subset (Simple / Error / Int / Bulk / Nil / Array) exclusively. Adding new variants is non-breaking: an exhaustive match on Reply is forced to opt into RESP3 by listing each variant (rust 2024 will not warn on missing arms only after #[non_exhaustive] — which we deliberately omit so RESP2-only code stays compile-checked for completeness).

Variants§

§

Simple(Vec<u8>)

+OK

§

Error(Vec<u8>)

-ERR ...

§

Int(i64)

:42

§

Bulk(Vec<u8>)

$5\r\nhello\r\n

§

Nil

$-1 or *-1 — the RESP2 null sentinel; in RESP3 the dedicated Reply::Null (_\r\n) is used instead. Both round-trip here.

§

Array(Vec<Reply>)

*N ...

§

Map(Vec<(Reply, Reply)>)

Resp3: %N\r\n<key1><value1>...<keyN><valueN> — N pairs (the header count is the pair count, NOT the element count, so a map of 3 pairs is %3 plus 6 sub-replies). Parsed/exposed as a Vec of pairs so duplicate keys + insertion order are preserved.

§

Set(Vec<Reply>)

Resp3: ~N\r\n<item1>...<itemN> — set semantics on the wire; dedup is the application’s job (RESP3 doesn’t require it).

§

Double(f64)

Resp3: ,1.5\r\n — double. inf / -inf / nan are valid payloads per the RESP3 spec and survive the round-trip.

§

Boolean(bool)

Resp3: #t\r\n / #f\r\n — boolean.

§

Verbatim

Resp3: =15\r\ntxt:Some bytes\r\n — verbatim string carrying a 3-char format tag (txt / mkd / etc.) + raw bytes. The colon separator is part of the wire encoding but not part of data.

Fields

§fmt: [u8; 3]

3-char format tag (e.g. b"txt" for plain text, b"mkd" for markdown).

§data: Vec<u8>

Payload bytes following the : separator.

§

BigNumber(Vec<u8>)

Resp3: (170141183460469231731687303715884105727\r\n — arbitrary- precision integer; carried as the raw digit bytes since we don’t pull in a bignum crate (charter: zero deps).

§

Null

Resp3: _\r\n — true null. RESP2 falls back to Reply::Nil.

§

Push(Vec<Reply>)

Resp3: >N\r\n... — like Reply::Array but tagged as an out-of-band server-push frame (pub/sub messages in RESP3). The client must dispatch these separately from regular replies.

§

BlobError(Vec<u8>)

Resp3: !8\r\nERR ohno\r\n — error carried as a length-prefixed bulk (handles errors containing CRLF that the simple-string - shape can’t encode).

Trait Implementations§

Source§

impl Clone for Reply

Source§

fn clone(&self) -> Reply

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 Reply

Source§

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

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

impl PartialEq for Reply

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Reply

Auto Trait Implementations§

§

impl Freeze for Reply

§

impl RefUnwindSafe for Reply

§

impl Send for Reply

§

impl Sync for Reply

§

impl Unpin for Reply

§

impl UnsafeUnpin for Reply

§

impl UnwindSafe for Reply

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