Enum redis_protocol::resp3::types::Frame[][src]

pub enum Frame {
Show 16 variants BlobString { data: Vec<u8>, attributes: Option<Attributes>, }, BlobError { data: Vec<u8>, attributes: Option<Attributes>, }, SimpleString { data: String, attributes: Option<Attributes>, }, SimpleError { data: String, attributes: Option<Attributes>, }, Boolean { data: bool, attributes: Option<Attributes>, }, Null, Number { data: i64, attributes: Option<Attributes>, }, Double { data: f64, attributes: Option<Attributes>, }, BigNumber { data: Vec<u8>, attributes: Option<Attributes>, }, VerbatimString { data: Vec<u8>, 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(Vec<u8>),
}
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: Vec<u8>
attributes: Option<Attributes>

A binary-safe blob.

BlobError

Fields

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

A binary-safe blob representing an error.

SimpleString

Fields

data: String
attributes: Option<Attributes>

A small non binary-safe string.

SimpleError

Fields

data: String
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: Vec<u8>
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: Vec<u8>
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(Vec<u8>)

Tuple Fields

0: Vec<u8>

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.

Number and Double will not be returned as a byte slice. Use number_or_double_as_bytes instead.

Attempt the read the frame as bytes if the inner type is an i64 or f64.

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

Performs the conversion.

Performs the conversion.

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.

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.

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

Converts self into T using Into<T>. Read more

Converts self into a target type. Read more

Causes self to use its Binary implementation when Debug-formatted.

Causes self to use its Display implementation when Debug-formatted. Read more

Causes self to use its LowerExp implementation when Debug-formatted. Read more

Causes self to use its LowerHex implementation when Debug-formatted. Read more

Causes self to use its Octal implementation when Debug-formatted.

Causes self to use its Pointer implementation when Debug-formatted. Read more

Causes self to use its UpperExp implementation when Debug-formatted. Read more

Causes self to use its UpperHex implementation when Debug-formatted. Read more

Performs the conversion.

Performs the conversion.

Pipes by value. This is generally the method you want to use. Read more

Borrows self and passes that borrow into the pipe function. Read more

Mutably borrows self and passes that borrow into the pipe function. Read more

Borrows self, then passes self.borrow() into the pipe function. Read more

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more

Borrows self, then passes self.as_ref() into the pipe function.

Mutably borrows self, then passes self.as_mut() into the pipe function. Read more

Borrows self, then passes self.deref() into the pipe function.

Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more

Pipes a value into a function that cannot ordinarily be called in suffix position. Read more

Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more

Pipes a dereference into a function that cannot normally be called in suffix position. Read more

Pipes a mutable dereference into a function that cannot normally be called in suffix position. Read more

Pipes a reference into a function that cannot ordinarily be called in suffix position. Read more

Pipes a mutable reference into a function that cannot ordinarily be called in suffix position. Read more

Immutable access to a value. Read more

Mutable access to a value. Read more

Immutable access to the Borrow<B> of a value. Read more

Mutable access to the BorrowMut<B> of a value. Read more

Immutable access to the AsRef<R> view of a value. Read more

Mutable access to the AsMut<R> view of a value. Read more

Immutable access to the Deref::Target of a value. Read more

Mutable access to the Deref::Target of a value. Read more

Calls .tap() only in debug builds, and is erased in release builds.

Calls .tap_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more

Provides immutable access for inspection. Read more

Calls tap in debug builds, and does nothing in release builds.

Provides mutable access for modification. Read more

Calls tap_mut in debug builds, and does nothing in release builds.

Provides immutable access to the reference for inspection.

Calls tap_ref in debug builds, and does nothing in release builds.

Provides mutable access to the reference for modification.

Calls tap_ref_mut in debug builds, and does nothing in release builds.

Provides immutable access to the borrow for inspection. Read more

Calls tap_borrow in debug builds, and does nothing in release builds.

Provides mutable access to the borrow for modification.

Calls tap_borrow_mut in debug builds, and does nothing in release builds. Read more

Immutably dereferences self for inspection.

Calls tap_deref in debug builds, and does nothing in release builds.

Mutably dereferences self for modification.

Calls tap_deref_mut in debug builds, and does nothing in release builds. Read more

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

Attempts to convert self into T using TryInto<T>. Read more

Attempts to convert self into a target type. 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.