DataStream

Struct DataStream 

Source
pub struct DataStream { /* private fields */ }
Expand description

Data stream manager.

Manages subscriptions and handles incoming data.

Implementations§

Source§

impl DataStream

Source

pub fn new(config: StreamConfig) -> Self

Create a new data stream.

Source

pub fn state(&self) -> ConnectionState

Get connection state.

Source

pub fn set_state(&self, state: ConnectionState)

Set connection state.

Source

pub fn subscribe(&self, subscription: StreamSubscription) -> String

Subscribe to a data source.

Source

pub fn unsubscribe(&self, id: &str)

Unsubscribe from a data source.

Source

pub fn get_subscription(&self, id: &str) -> Option<StreamSubscription>

Get subscription by ID.

Source

pub fn subscriptions(&self) -> Vec<StreamSubscription>

Get all active subscriptions.

Source

pub fn get_data(&self, id: &str) -> Option<Value>

Get cached data for a subscription.

Source

pub fn handle_message(&self, msg: StreamMessage) -> Option<StreamMessage>

Handle an incoming message.

Source

pub fn take_outbox(&self) -> Vec<StreamMessage>

Take pending outbound messages.

Source

pub fn send(&self, msg: StreamMessage)

Queue an outbound message.

Source

pub fn reconnect_delay(&self) -> Duration

Get reconnection delay based on current attempts.

Source

pub fn increment_reconnect_attempts(&self)

Increment reconnection attempts.

Source

pub fn reset_reconnect_attempts(&self)

Reset reconnection attempts.

Source

pub fn should_reconnect(&self) -> bool

Check if we should try to reconnect.

Source

pub fn resubscribe_all(&self)

Resubscribe all subscriptions (after reconnect).

Source

pub fn subscription_count(&self) -> usize

Number of active subscriptions.

Source

pub fn clear(&self)

Clear all subscriptions and cache.

Trait Implementations§

Source§

impl Default for DataStream

Source§

fn default() -> DataStream

Returns the “default value” for a type. Read more

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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