Trait Resp3Frame

Source
pub trait Resp3Frame:
    Debug
    + Hash
    + Eq
    + Sized {
    type Attributes;

Show 25 methods // Required methods fn from_buffer( target: FrameKind, buf: impl IntoIterator<Item = Self>, attributes: Option<Self::Attributes>, ) -> Result<Self, RedisProtocolError>; fn attributes(&self) -> Option<&Self::Attributes>; fn take_attributes(&mut self) -> Option<Self::Attributes>; fn attributes_mut(&mut self) -> Option<&mut Self::Attributes>; fn add_attributes( &mut self, attributes: Self::Attributes, ) -> Result<(), RedisProtocolError>; fn new_end_stream() -> Self; fn new_empty() -> Self; fn len(&self) -> usize; fn take(&mut self) -> Self; fn kind(&self) -> FrameKind; fn is_end_stream_frame(&self) -> bool; fn verbatim_string_format(&self) -> Option<&VerbatimStringFormat>; fn as_str(&self) -> Option<&str>; fn as_bool(&self) -> Option<bool>; fn to_string(&self) -> Option<String>; fn as_bytes(&self) -> Option<&[u8]>; fn encode_len(&self, int_as_blobstring: bool) -> usize; fn is_normal_pubsub_message(&self) -> bool; fn is_pattern_pubsub_message(&self) -> bool; fn is_shard_pubsub_message(&self) -> bool; fn is_single_element_vec(&self) -> bool; fn pop_or_take(self) -> Self; // Provided methods fn is_redirection(&self) -> bool { ... } fn as_f64(&self) -> Option<f64> { ... } fn convert<T>(self) -> Result<T, RedisProtocolError> where Self: Sized, T: FromResp3<Self> { ... }
}
Available on crate feature resp3 only.
Expand description

Generic operations on a RESP3 frame.

Required Associated Types§

Required Methods§

Source

fn from_buffer( target: FrameKind, buf: impl IntoIterator<Item = Self>, attributes: Option<Self::Attributes>, ) -> Result<Self, RedisProtocolError>

Create the target aggregate type based on a buffered set of chunked frames.

Source

fn attributes(&self) -> Option<&Self::Attributes>

Read the attributes attached to the frame.

Source

fn take_attributes(&mut self) -> Option<Self::Attributes>

Take the attributes off this frame.

Source

fn attributes_mut(&mut self) -> Option<&mut Self::Attributes>

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

Source

fn add_attributes( &mut self, attributes: Self::Attributes, ) -> Result<(), RedisProtocolError>

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

Source

fn new_end_stream() -> Self

Create a new frame that terminates a stream.

Source

fn new_empty() -> Self

Create a new empty frame with attribute support.

Source

fn len(&self) -> usize

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.

Source

fn take(&mut self) -> Self

Replace self with Null, returning the original value.

Source

fn kind(&self) -> FrameKind

Read the associated FrameKind.

Source

fn is_end_stream_frame(&self) -> bool

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

Source

fn verbatim_string_format(&self) -> Option<&VerbatimStringFormat>

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

Source

fn as_str(&self) -> Option<&str>

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

Source

fn as_bool(&self) -> Option<bool>

Attempt to convert the frame to a bool.

Source

fn to_string(&self) -> Option<String>

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

Source

fn as_bytes(&self) -> Option<&[u8]>

Attempt to read the frame as a byte slice.

Source

fn encode_len(&self, int_as_blobstring: bool) -> usize

Read the number of bytes necessary to represent the frame and any associated attributes.

Source

fn is_normal_pubsub_message(&self) -> bool

Whether the frame is a message from a subscribe call.

Source

fn is_pattern_pubsub_message(&self) -> bool

Whether the frame is a message from a psubscribe call.

Source

fn is_shard_pubsub_message(&self) -> bool

Whether the frame is a message from a ssubscribe call.

Source

fn is_single_element_vec(&self) -> bool

Available on crate feature convert only.

Whether frame is a bulk array with a single element.

Source

fn pop_or_take(self) -> Self

Available on crate feature convert only.

Pop an element from the inner array or return the original frame.

This function is intended to be used with Self::is_single_element_vec and may panic.

Provided Methods§

Source

fn is_redirection(&self) -> bool

Whether the frame is a MOVED or ASK redirection.

Source

fn as_f64(&self) -> Option<f64>

Convert the frame to a double.

Source

fn convert<T>(self) -> Result<T, RedisProtocolError>
where Self: Sized, T: FromResp3<Self>,

Available on crate feature convert only.

Convert the frame to another type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§