Skip to main content

WebSocketReadResponse

Struct WebSocketReadResponse 

Source
pub struct WebSocketReadResponse {
    pub messages: Vec<BufferedMessage>,
    pub latest_index: Option<u64>,
    pub oldest_index: Option<u64>,
}
Expand description

Response for WebSocket read operations.

This struct captures the read result with messages and buffer state information.

§Gap Detection

Consumers can detect gaps by comparing message indices. Each BufferedMessage contains an index field that increases monotonically. If there’s a gap between indices, some messages were evicted from the buffer.

§Convenience Methods

For common access patterns, use the convenience methods instead of accessing fields directly:

// Instead of:
let data = response.messages.first().unwrap().content.as_data().unwrap();

// Use:
let data = response.first_data().unwrap();

Fields§

§messages: Vec<BufferedMessage>

All requested messages (based on read mode).

§latest_index: Option<u64>

Current highest index in buffer (for tracking).

§oldest_index: Option<u64>

Current lowest index in buffer (helpful for gap detection).

Implementations§

Source§

impl WebSocketReadResponse

Source

pub fn has_messages(&self) -> bool

Returns true if there are any messages in the response.

Source

pub fn message_count(&self) -> usize

Returns the number of messages in the response.

Source

pub fn first_message(&self) -> Option<&BufferedMessage>

Get the first (oldest) message, if any.

Source

pub fn latest_message(&self) -> Option<&BufferedMessage>

Get the last (most recent) message, if any.

Source

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

Get the data from the first message (convenience for common pattern).

Returns None if there are no messages or if the first message is a system message.

Source

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

Get the data from the latest message (convenience for common pattern).

Returns None if there are no messages or if the latest message is a system message.

Source

pub fn data_messages(&self) -> impl Iterator<Item = &BufferedMessage>

Iterate over only the data messages (filtering out system messages).

Source

pub fn iter_data(&self) -> impl Iterator<Item = &[u8]>

Iterate over only the data bytes (convenience for processing).

This filters out system messages and returns only the raw data bytes.

Source

pub fn data_message_count(&self) -> usize

Returns the number of data messages (excluding system messages).

Source

pub fn has_system_messages(&self) -> bool

Returns true if any message is a system message (like OversizedWarning).

Trait Implementations§

Source§

impl BorshDeserialize for WebSocketReadResponse

Source§

fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>

Source§

fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
Source§

fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
Source§

fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>
where R: Read,

Source§

impl BorshSerialize for WebSocketReadResponse

Source§

fn serialize<__W: Write>(&self, writer: &mut __W) -> Result<(), Error>

Source§

impl Clone for WebSocketReadResponse

Source§

fn clone(&self) -> WebSocketReadResponse

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 WebSocketReadResponse

Source§

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

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

impl<'de> Deserialize<'de> for WebSocketReadResponse

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for WebSocketReadResponse

Source§

impl PartialEq for WebSocketReadResponse

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for WebSocketReadResponse

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for WebSocketReadResponse

Auto Trait Implementations§

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<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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoRexValueFor<T> for T
where T: BorshSerialize,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<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