Trait Resp2Frame

Source
pub trait Resp2Frame:
    Debug
    + Hash
    + Eq {
Show 15 methods // Required methods fn take(&mut self) -> Self; fn kind(&self) -> FrameKind; fn as_str(&self) -> Option<&str>; fn as_bool(&self) -> Option<bool>; fn as_bytes(&self) -> Option<&[u8]>; fn to_string(&self) -> Option<String>; fn encode_len(&self, int_as_bulkstring: 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: FromResp2<Self> { ... }
}
Available on crate feature resp2 only.
Expand description

Generic operations on a RESP2 frame.

Required Methods§

Source

fn take(&mut self) -> Self

Replace self with Null, returning the original value.

Source

fn kind(&self) -> FrameKind

Read the FrameKind value for this frame.

Source

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

Attempt to read the frame value as a string slice.

Source

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

Convert the value to a boolean.

Source

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

Attempt to read the frame value as a byte slice.

Source

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

Copy and read the inner value as a string, if possible.

Source

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

Read the number of bytes needed to encode this frame.

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: FromResp2<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§