pub enum Frame {
}
Expand description
Frame represents a single RESP data transmit unit over the socket.
more on the RESP protocol can be found here
Variants§
SimpleString(String)
SimpleError(String)
Integer(i64)
BulkString(Bytes)
Array(Vec<Frame>)
Null
Boolean(bool)
Double(f64)
BigNumber(BigInt)
BulkError(Bytes)
VerbatimString(Bytes, Bytes)
Map(Vec<(Frame, Frame)>)
Attribute
Set(Vec<Frame>)
Push
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn push_frame_to_array(&mut self, frame: Frame) -> Result<()>
pub fn push_frame_to_array(&mut self, frame: Frame) -> Result<()>
Sourcepub async fn serialize(&self) -> Result<Bytes>
pub async fn serialize(&self) -> Result<Bytes>
Serializes a Frame into a bytes buffer.
The returned value is a smart pointer only counting reference. It is cheap to clone.
Caller can get the underlying slice by calling as_slice
or as_ref
on the returned value.
It is almost 0 cost to get the slice.
§Returns
A Result containing the serialized bytes buffer
Sourcepub async fn deserialize(buf: Bytes) -> Result<Frame>
pub async fn deserialize(buf: Bytes) -> Result<Frame>
Sourcepub fn try_parse(cursor: &mut Cursor<&[u8]>) -> Result<Frame>
pub fn try_parse(cursor: &mut Cursor<&[u8]>) -> Result<Frame>
Tries parsing a Frame from the buffer.
This method wraps the input with a cursor to track the current version as we need to make resursive calls. Using a cursor avoids the need to split the buffer or passing an additional parameter.
§Returns
Ok(usize)
if the buffer contains a complete frame, the number of bytes needed to parse the frameErr(RedisError::IncompleteFrame)
if the buffer contains an incomplete frameErr(RedisError::InvalidFrame)
if the buffer contains an invalid frame
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Frame
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin for Frame
impl UnwindSafe for Frame
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more