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> { ... }
}
resp3
only.Expand description
Generic operations on a RESP3 frame.
Required Associated Types§
type Attributes
Required Methods§
Sourcefn from_buffer(
target: FrameKind,
buf: impl IntoIterator<Item = Self>,
attributes: Option<Self::Attributes>,
) -> Result<Self, RedisProtocolError>
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.
Sourcefn attributes(&self) -> Option<&Self::Attributes>
fn attributes(&self) -> Option<&Self::Attributes>
Read the attributes attached to the frame.
Sourcefn take_attributes(&mut self) -> Option<Self::Attributes>
fn take_attributes(&mut self) -> Option<Self::Attributes>
Take the attributes off this frame.
Sourcefn attributes_mut(&mut self) -> Option<&mut Self::Attributes>
fn attributes_mut(&mut self) -> Option<&mut Self::Attributes>
Read a mutable reference to any attributes attached to the frame.
Sourcefn add_attributes(
&mut self,
attributes: Self::Attributes,
) -> Result<(), RedisProtocolError>
fn add_attributes( &mut self, attributes: Self::Attributes, ) -> Result<(), RedisProtocolError>
Attempt to add attributes to the frame, extending the existing attributes if needed.
Sourcefn new_end_stream() -> Self
fn new_end_stream() -> Self
Create a new frame that terminates a stream.
Sourcefn len(&self) -> usize
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.
Sourcefn is_end_stream_frame(&self) -> bool
fn is_end_stream_frame(&self) -> bool
Whether the frame is an empty chunked string, signifying the end of a chunked string stream.
Sourcefn verbatim_string_format(&self) -> Option<&VerbatimStringFormat>
fn verbatim_string_format(&self) -> Option<&VerbatimStringFormat>
If the frame is a verbatim string then read the associated format.
Sourcefn as_str(&self) -> Option<&str>
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.
Sourcefn to_string(&self) -> Option<String>
fn to_string(&self) -> Option<String>
Read the frame as a String
if it can be parsed as a UTF-8 string.
Sourcefn encode_len(&self, int_as_blobstring: bool) -> usize
fn encode_len(&self, int_as_blobstring: bool) -> usize
Read the number of bytes necessary to represent the frame and any associated attributes.
Sourcefn is_normal_pubsub_message(&self) -> bool
fn is_normal_pubsub_message(&self) -> bool
Whether the frame is a message from a subscribe
call.
Sourcefn is_pattern_pubsub_message(&self) -> bool
fn is_pattern_pubsub_message(&self) -> bool
Whether the frame is a message from a psubscribe
call.
Sourcefn is_shard_pubsub_message(&self) -> bool
fn is_shard_pubsub_message(&self) -> bool
Whether the frame is a message from a ssubscribe
call.
Sourcefn is_single_element_vec(&self) -> bool
Available on crate feature convert
only.
fn is_single_element_vec(&self) -> bool
convert
only.Whether frame is a bulk array with a single element.
Sourcefn pop_or_take(self) -> Self
Available on crate feature convert
only.
fn pop_or_take(self) -> Self
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§
Sourcefn is_redirection(&self) -> bool
fn is_redirection(&self) -> bool
Whether the frame is a MOVED
or ASK
redirection.
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.