pub enum Frame {
Show 16 variants BlobString { data: Bytes, attributes: Option<Attributes>, }, BlobError { data: Bytes, attributes: Option<Attributes>, }, SimpleString { data: Bytes, attributes: Option<Attributes>, }, SimpleError { data: Str, attributes: Option<Attributes>, }, Boolean { data: bool, attributes: Option<Attributes>, }, Null, Number { data: i64, attributes: Option<Attributes>, }, Double { data: f64, attributes: Option<Attributes>, }, BigNumber { data: Bytes, attributes: Option<Attributes>, }, VerbatimString { data: Bytes, format: VerbatimStringFormat, attributes: Option<Attributes>, }, Array { data: Vec<Frame>, attributes: Option<Attributes>, }, Map { data: FrameMap, attributes: Option<Attributes>, }, Set { data: FrameSet, attributes: Option<Attributes>, }, Push { data: Vec<Frame>, attributes: Option<Attributes>, }, Hello { version: RespVersion, auth: Option<Auth>, }, ChunkedString(Bytes),
}
Expand description

An enum describing the possible data types in RESP3 along with the corresponding Rust data type to represent the payload.

https://github.com/antirez/RESP3/blob/master/spec.md

Variants

BlobString

Fields

data: Bytes
attributes: Option<Attributes>

A binary-safe blob.

BlobError

Fields

data: Bytes
attributes: Option<Attributes>

A binary-safe blob representing an error.

SimpleString

Fields

data: Bytes
attributes: Option<Attributes>

A small non binary-safe string.

The internal data type is Bytes in order to support callers that use this interface to parse a MONITOR stream.

SimpleError

Fields

data: Str
attributes: Option<Attributes>

A small non binary-safe string representing an error.

Boolean

Fields

data: bool
attributes: Option<Attributes>

A boolean type.

Null

A null type.

Number

Fields

data: i64
attributes: Option<Attributes>

A signed 64 bit integer.

Double

Fields

data: f64
attributes: Option<Attributes>

A signed 64 bit floating point number.

BigNumber

Fields

data: Bytes
attributes: Option<Attributes>

A large number not representable as a Number or Double.

This library does not attempt to parse this, nor does it offer any utilities to do so.

VerbatimString

Fields

data: Bytes
attributes: Option<Attributes>

A binary-safe string to be displayed without any escaping or filtering.

Array

Fields

data: Vec<Frame>
attributes: Option<Attributes>

An array of frames, arbitrarily nested.

Map

Fields

data: FrameMap
attributes: Option<Attributes>

An unordered map of key-value pairs.

According to the spec keys can be any other RESP3 data type. However, it doesn’t make sense to implement Hash for certain Rust data types like HashMap, Vec, HashSet, etc, so this library limits the possible data types for keys to only those that can be hashed in a semi-sane way.

For example, attempting to create a Frame::Map<HashMap<Frame::Set<HashSet<Frame>>, Frame::Foo>> from bytes will panic.

Set

Fields

data: FrameSet
attributes: Option<Attributes>

An unordered collection of other frames with a uniqueness constraint.

Push

Fields

data: Vec<Frame>
attributes: Option<Attributes>

Out-of-band data to be returned to the caller if necessary.

Hello

Fields

version: RespVersion
auth: Option<Auth>

A special frame type used when first connecting to the server to describe the protocol version and optional credentials.

ChunkedString(Bytes)

One chunk of a streaming string.

Implementations

Whether or not the frame can be used as a key in a HashMap or HashSet.

Not all frame types can be hashed, and trying to do so can panic. This function can be used to handle this gracefully.

Read the attributes attached to the frame.

Take the attributes off this frame.

Read a mutable reference to any attributes attached to the frame.

Attempt to add attributes to the frame, extending the existing attributes if needed.

Create a new Frame that terminates a stream.

A context-aware length function that returns the length of the inner frame contents.

This does not return the encoded length, but rather the length of the contents of the frame such as the number of elements in an array, the size of any inner buffers, etc.

Note: Null has a length of 0 and Hello, Number, Double, and Boolean have a length of 1.

See encode_len to read the number of bytes necessary to encode the frame.

Replace self with Null, returning the original value.

Read the associated FrameKind.

Whether or not the frame is a Null variant.

Whether or not the frame represents an array of frames.

Whether or not the frame represents data pushed to the client from the server.

Whether or not the frame is a boolean value.

Whether or not the frame represents an error.

Whether or not the frame is an array, map, or set.

Whether or not the frame represents a BlobString or BlobError.

Whether or not the frame represents a chunked string.

Whether or not the frame is an empty chunked string, signifying the end of a chunked string stream.

Whether or not the frame is a verbatim string.

If the frame is a verbatim string then read the associated format.

Read the frame as a string slice if it can be parsed as a UTF-8 string without allocating.

Numbers and Doubles will not be cast to a string since that would require allocating.

Read the frame as a String if it can be parsed as a UTF-8 string.

Attempt to read the frame as a byte slice.

Attempt to read the frame as an i64.

Attempt to read the frame as an f64.

Whether or not the frame represents a MOVED or ASK error.

Attempt to parse the frame as a cluster redirection error.

Whether or not the frame represents a publish-subscribe message, but not a pattern publish-subscribe message.

Whether or not the frame represents a message on a publish-subscribe channel.

Whether or not the frame represents a message on a publish-subscribe channel matched against a pattern subscription.

Attempt to parse the frame as a publish-subscribe message, returning the (channel, message) tuple if successful, or the original frame if the inner data is not a publish-subscribe message.

Attempt to read the number of bytes needed to encode the frame.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.