Skip to main content

Frame

Enum Frame 

Source
pub enum Frame {
Show 32 variants SimpleString(Bytes), Error(Bytes), Integer(i64), BulkString(Option<Bytes>), BlobError(Bytes), StreamedStringHeader, StreamedBlobErrorHeader, StreamedVerbatimStringHeader, StreamedArrayHeader, StreamedSetHeader, StreamedMapHeader, StreamedAttributeHeader, StreamedPushHeader, StreamedStringChunk(Bytes), StreamedString(Vec<Bytes>), StreamedArray(Vec<Frame>), StreamedSet(Vec<Frame>), StreamedMap(Vec<(Frame, Frame)>), StreamedAttribute(Vec<(Frame, Frame)>), StreamedPush(Vec<Frame>), StreamTerminator, Null, Double(f64), SpecialFloat(Bytes), Boolean(bool), BigNumber(Bytes), VerbatimString(Bytes, Bytes), Array(Option<Vec<Frame>>), Set(Vec<Frame>), Map(Vec<(Frame, Frame)>), Attribute(Vec<(Frame, Frame)>), Push(Vec<Frame>),
}
Expand description

A parsed RESP3 frame.

Each variant corresponds to one of the RESP3 types, including both fixed-length and streaming headers for bulk strings, arrays, sets, maps, attributes, and pushes.

Variants§

§

SimpleString(Bytes)

Simple string: +<string>\r\n

§

Error(Bytes)

Simple error: -<error>\r\n

§

Integer(i64)

Integer: :<number>\r\n

§

BulkString(Option<Bytes>)

Blob string: $<length>\r\n<bytes>\r\n

§

BlobError(Bytes)

Blob error: !<length>\r\n<bytes>\r\n

§

StreamedStringHeader

Streaming blob string header: $?\r\n

§

StreamedBlobErrorHeader

Streaming blob error header: !?\r\n

§

StreamedVerbatimStringHeader

Streaming verbatim string header: =?\r\n

§

StreamedArrayHeader

Streaming array header: *?\r\n

§

StreamedSetHeader

Streaming set header: ~?\r\n

§

StreamedMapHeader

Streaming map header: %?\r\n

§

StreamedAttributeHeader

Streaming attribute header: |?\r\n

§

StreamedPushHeader

Streaming push header: >?\r\n

§

StreamedStringChunk(Bytes)

Streaming string chunk: ;length\r\ndata\r\n

Represents an individual chunk in a streaming string sequence. These chunks are parsed from ;{length}\r\n{data}\r\n format. A zero-length chunk (;0\r\n) indicates the end of the stream.

§Example

use resp_rs::resp3::Frame;
use bytes::Bytes;

// Chunk containing "Hello"
// Wire format: ;5\r\nHello\r\n
Frame::StreamedStringChunk(Bytes::from("Hello"));
§

StreamedString(Vec<Bytes>)

Accumulated streaming string data from multiple chunks

Created by parse_streaming_sequence() when parsing a complete streaming string sequence ($?\r\n + chunks + ;0\r\n). Contains all chunks in order, allowing reconstruction of the full string.

§Example

use resp_rs::resp3::Frame;
use bytes::Bytes;

// Represents "Hello world" from chunks ["Hello ", "world"]
Frame::StreamedString(vec![
    Bytes::from("Hello "),
    Bytes::from("world")
]);
§

StreamedArray(Vec<Frame>)

Accumulated streaming array data from multiple chunks

Created when parsing a streaming array sequence (*?\r\n + frames + .\r\n). Contains all frames that were streamed as part of the array.

§Example

use resp_rs::resp3::Frame;
use bytes::Bytes;

// Array with mixed types
Frame::StreamedArray(vec![
    Frame::SimpleString(Bytes::from("hello")),
    Frame::Integer(42),
    Frame::Boolean(true)
]);
§

StreamedSet(Vec<Frame>)

Accumulated streaming set data from multiple chunks

Created when parsing a streaming set sequence (~?\r\n + frames + .\r\n). Contains all unique elements that were streamed as part of the set.

§

StreamedMap(Vec<(Frame, Frame)>)

Accumulated streaming map data from multiple chunks

Created when parsing a streaming map sequence (%?\r\n + key-value pairs + .\r\n). Contains all key-value pairs that were streamed as part of the map.

§Example

use resp_rs::resp3::Frame;
use bytes::Bytes;

Frame::StreamedMap(vec![
    (Frame::SimpleString(Bytes::from("name")), Frame::SimpleString(Bytes::from("Alice"))),
    (Frame::SimpleString(Bytes::from("age")), Frame::Integer(25))
]);
§

StreamedAttribute(Vec<(Frame, Frame)>)

Accumulated streaming attribute data from multiple chunks

Created when parsing a streaming attribute sequence (|?\r\n + key-value pairs + .\r\n). Attributes provide out-of-band metadata that doesn’t affect the main data structure.

§

StreamedPush(Vec<Frame>)

Accumulated streaming push data from multiple chunks

Created when parsing a streaming push sequence (>?\r\n + frames + .\r\n). Push messages are server-initiated communications (e.g., pub/sub messages).

§Example

use resp_rs::resp3::Frame;
use bytes::Bytes;

// Pub/sub message
Frame::StreamedPush(vec![
    Frame::SimpleString(Bytes::from("pubsub")),
    Frame::SimpleString(Bytes::from("channel1")),
    Frame::SimpleString(Bytes::from("message content"))
]);
§

StreamTerminator

End-of-stream terminator for all chunked sequences: .\r\n

§

Null

Null: _\r\n

§

Double(f64)

Double: ,<float>\r\n

§

SpecialFloat(Bytes)

Special Float: ,inf\r\n, -inf\r\n, nan\r\n

§

Boolean(bool)

Boolean: #t\r\n or #f\r\n

§

BigNumber(Bytes)

Big number: (<number>\r\n

§

VerbatimString(Bytes, Bytes)

Verbatim string: =format:content\r\n

§

Array(Option<Vec<Frame>>)

Array: *<count>\r\n… (or streaming header *?\r\n)

§

Set(Vec<Frame>)

Set: ~<count>\r\n… (or streaming header ~?\r\n)

§

Map(Vec<(Frame, Frame)>)

Map: %<count>\r\n… (or streaming header %?\r\n)

§

Attribute(Vec<(Frame, Frame)>)

Attribute: |<count>\r\n… (or streaming header |?\r\n)

§

Push(Vec<Frame>)

Push: > <count>\r\n… (or streaming header >?\r\n)

Implementations§

Source§

impl Frame

Source

pub fn as_bytes(&self) -> Option<&Bytes>

Returns the bytes if this is a string-like frame (SimpleString, Error, BulkString, BlobError, or BigNumber).

For BulkString(None) (null), returns None.

Source

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

Returns the string data as a UTF-8 &str, if this is a string-like frame and contains valid UTF-8.

Source

pub fn as_integer(&self) -> Option<i64>

Returns the integer value if this is an Integer frame.

Source

pub fn as_double(&self) -> Option<f64>

Returns the double value if this is a Double frame.

Source

pub fn as_boolean(&self) -> Option<bool>

Returns the boolean value if this is a Boolean frame.

Source

pub fn as_array(&self) -> Option<&[Frame]>

Returns a reference to the array items if this is an Array.

For Array(None) (null), returns None.

Source

pub fn as_set(&self) -> Option<&[Frame]>

Returns a reference to the set items if this is a Set.

Source

pub fn as_map(&self) -> Option<&[(Frame, Frame)]>

Returns a reference to the map pairs if this is a Map.

Source

pub fn as_push(&self) -> Option<&[Frame]>

Returns a reference to the push items if this is a Push.

Source

pub fn as_verbatim_string(&self) -> Option<(&Bytes, &Bytes)>

Returns the verbatim string format and content if this is a VerbatimString.

Source

pub fn into_array(self) -> Result<Vec<Frame>, Frame>

Consumes the frame and returns the array items.

Returns Err(self) if this is not a non-null Array.

Source

pub fn into_bulk_string(self) -> Result<Bytes, Frame>

Consumes the frame and returns the bulk string bytes.

Returns Err(self) if this is not a non-null BulkString.

Source

pub fn into_map(self) -> Result<Vec<(Frame, Frame)>, Frame>

Consumes the frame and returns the map pairs.

Returns Err(self) if this is not a Map.

Source

pub fn into_set(self) -> Result<Vec<Frame>, Frame>

Consumes the frame and returns the set items.

Returns Err(self) if this is not a Set.

Source

pub fn is_null(&self) -> bool

Returns true if this is Null or a null bulk string/array.

Source

pub fn is_error(&self) -> bool

Returns true if this is an Error or BlobError frame.

Trait Implementations§

Source§

impl Clone for Frame

Source§

fn clone(&self) -> Frame

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Frame

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Encoder<Frame> for RespCodec

Source§

type Error = ProtocolError

The type of encoding errors. Read more
Source§

fn encode( &mut self, item: Frame, dst: &mut BytesMut, ) -> Result<(), ProtocolError>

Encodes a frame into the buffer provided. Read more
Source§

impl FromFrame for Frame

Source§

fn from_frame(frame: Frame) -> Result<Frame, RedisError>

Decode a response frame into this type. Read more
Source§

impl PartialEq for Frame

Source§

fn eq(&self, other: &Frame) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl RequestDeadline for Frame

Source§

fn request_deadline(&self) -> Option<Instant>

Return the request’s absolute deadline, if it carries one.
Source§

impl Service<Frame> for FrameService

Source§

type Response = Frame

Responses given by the service.
Source§

type Error = RedisError

Errors produced by the service.
Source§

type Future = Pin<Box<dyn Future<Output = Result<Frame, RedisError>> + Send>>

The future response value.
Source§

fn poll_ready( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(), <FrameService as Service<Frame>>::Error>>

Returns Poll::Ready(Ok(())) when the service is able to process requests. Read more
Source§

fn call(&mut self, request: Frame) -> <FrameService as Service<Frame>>::Future

Process the request and return the response asynchronously. Read more
Source§

impl Service<Frame> for AutoPipelineService

Source§

type Response = Frame

Responses given by the service.
Source§

type Error = RedisError

Errors produced by the service.
Source§

type Future = Pin<Box<dyn Future<Output = Result<Frame, RedisError>> + Send>>

The future response value.
Source§

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>

Returns Poll::Ready(Ok(())) when the service is able to process requests. Read more
Source§

fn call(&mut self, frame: Frame) -> Self::Future

Process the request and return the response asynchronously. Read more
Source§

impl<S> Service<Frame> for CacheService<S>
where S: Service<Frame, Response = Frame, Error = RedisError> + ReleaseReadiness, S::Future: Send + 'static,

Source§

type Response = Frame

Responses given by the service.
Source§

type Error = RedisError

Errors produced by the service.
Source§

type Future = Pin<Box<dyn Future<Output = Result<Frame, RedisError>> + Send>>

The future response value.
Source§

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>

Returns Poll::Ready(Ok(())) when the service is able to process requests. Read more
Source§

fn call(&mut self, request: Frame) -> Self::Future

Process the request and return the response asynchronously. Read more
Source§

impl<S> Service<Frame> for RedisCircuitBreakerService<S>
where S: Service<Frame, Response = Frame, Error = RedisError> + Clone + Send + 'static, S::Future: Send + 'static,

Source§

type Response = Frame

Responses given by the service.
Source§

type Error = RedisError

Errors produced by the service.
Source§

type Future = Pin<Box<dyn Future<Output = Result<Frame, RedisError>> + Send>>

The future response value.
Source§

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>

Returns Poll::Ready(Ok(())) when the service is able to process requests. Read more
Source§

fn call(&mut self, request: Frame) -> Self::Future

Process the request and return the response asynchronously. Read more
Source§

impl<S, R> Service<Frame> for MetricsService<S, R>
where S: Service<Frame, Response = Frame, Error = RedisError>, S::Future: Send + 'static, R: MetricsRecorder,

Source§

type Response = Frame

Responses given by the service.
Source§

type Error = RedisError

Errors produced by the service.
Source§

type Future = Pin<Box<dyn Future<Output = Result<Frame, RedisError>> + Send>>

The future response value.
Source§

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>

Returns Poll::Ready(Ok(())) when the service is able to process requests. Read more
Source§

fn call(&mut self, request: Frame) -> Self::Future

Process the request and return the response asynchronously. Read more
Source§

impl Service<Frame> for ReconnectService

Source§

type Response = Frame

Responses given by the service.
Source§

type Error = RedisError

Errors produced by the service.
Source§

type Future = Pin<Box<dyn Future<Output = Result<Frame, RedisError>> + Send>>

The future response value.
Source§

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>

Returns Poll::Ready(Ok(())) when the service is able to process requests. Read more
Source§

fn call(&mut self, request: Frame) -> Self::Future

Process the request and return the response asynchronously. Read more
Source§

impl Service<Frame> for ResilientRedisClient

Source§

type Response = Frame

Responses given by the service.
Source§

type Error = RedisError

Errors produced by the service.
Source§

type Future = Pin<Box<dyn Future<Output = Result<Frame, RedisError>> + Send>>

The future response value.
Source§

fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>

Returns Poll::Ready(Ok(())) when the service is able to process requests. Read more
Source§

fn call(&mut self, request: Frame) -> Self::Future

Process the request and return the response asynchronously. Read more
Source§

impl<S> Service<Frame> for TracingService<S>
where S: Service<Frame, Response = Frame, Error = RedisError>, S::Future: Send + 'static,

Source§

type Response = Frame

Responses given by the service.
Source§

type Error = RedisError

Errors produced by the service.
Source§

type Future = Pin<Box<dyn Future<Output = Result<Frame, RedisError>> + Send>>

The future response value.
Source§

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>

Returns Poll::Ready(Ok(())) when the service is able to process requests. Read more
Source§

fn call(&mut self, request: Frame) -> Self::Future

Process the request and return the response asynchronously. Read more
Source§

impl StructuralPartialEq for Frame

Auto Trait Implementations§

§

impl !Freeze for Frame

§

impl RefUnwindSafe for Frame

§

impl Send for Frame

§

impl Sync for Frame

§

impl Unpin for Frame

§

impl UnsafeUnpin for Frame

§

impl UnwindSafe for Frame

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more