ManagedConnection

Struct ManagedConnection 

Source
pub struct ManagedConnection {
    pub id: ChannelId,
    pub ticker: Option<KiteTickerAsync>,
    pub subscriber: Option<KiteTickerSubscriber>,
    pub subscribed_symbols: HashMap<u32, Mode>,
    pub stats: Arc<RwLock<ConnectionStats>>,
    pub is_healthy: Arc<AtomicBool>,
    pub last_ping: Arc<AtomicU64>,
    pub task_handle: Option<JoinHandle<()>>,
    pub heartbeat_handle: Option<JoinHandle<()>>,
    pub message_sender: UnboundedSender<TickerMessage>,
    /* private fields */
}
Expand description

Represents a single WebSocket connection with its metadata

Fields§

§id: ChannelId§ticker: Option<KiteTickerAsync>§subscriber: Option<KiteTickerSubscriber>§subscribed_symbols: HashMap<u32, Mode>§stats: Arc<RwLock<ConnectionStats>>§is_healthy: Arc<AtomicBool>§last_ping: Arc<AtomicU64>§task_handle: Option<JoinHandle<()>>§heartbeat_handle: Option<JoinHandle<()>>§message_sender: UnboundedSender<TickerMessage>

Implementations§

Source§

impl ManagedConnection

Source

pub fn new( id: ChannelId, message_sender: UnboundedSender<TickerMessage>, ) -> Self

Source

pub async fn connect( &mut self, api_key: &str, access_token: &str, config: &KiteManagerConfig, ) -> Result<(), String>

Connect to WebSocket and start message processing

Source

pub async fn connect_with_raw( &mut self, api_key: &str, access_token: &str, config: &KiteManagerConfig, raw_only: bool, ) -> Result<(), String>

Connect with explicit raw_only flag

Source

pub async fn subscribe_symbols( &mut self, symbols: &[u32], mode: Mode, ) -> Result<(), String>

Subscribe to symbols on this connection

Source

pub async fn add_symbols( &mut self, symbols: &[u32], mode: Mode, ) -> Result<(), String>

Dynamically add new symbols to existing subscription

Source

pub async fn remove_symbols(&mut self, symbols: &[u32]) -> Result<(), String>

Dynamically remove symbols from existing subscription

Source

pub async fn start_message_processing(&mut self) -> Result<(), String>

Start message processing for the subscriber

Source

pub fn can_accept_symbols( &self, count: usize, max_per_connection: usize, ) -> bool

Check if connection can accept more symbols

Source

pub fn symbol_count(&self) -> usize

Get current symbol count

Source

pub fn is_healthy(&self) -> bool

Check if connection is healthy

Trait Implementations§

Source§

impl Debug for ManagedConnection

Source§

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

Formats the value using the given formatter. 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> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V