SessionState

Struct SessionState 

Source
pub struct SessionState {
Show 14 fields pub id: u64, pub peer_addr: SocketAddr, pub phase: SessionPhase, pub connected_at: Instant, pub handshake_completed_at: Option<Instant>, pub connect_params: Option<ConnectParams>, pub encoder_type: EncoderType, pub streams: HashMap<u32, StreamState>, pub in_chunk_size: u32, pub out_chunk_size: u32, pub window_ack_size: u32, pub bytes_received: u64, pub bytes_sent: u64, pub last_ack_sequence: u32, /* private fields */
}
Expand description

Complete session state

Fields§

§id: u64

Unique session ID

§peer_addr: SocketAddr

Remote peer address

§phase: SessionPhase

Current phase

§connected_at: Instant

Connection start time

§handshake_completed_at: Option<Instant>

Time when handshake completed

§connect_params: Option<ConnectParams>

Connect parameters (after connect command)

§encoder_type: EncoderType

Detected encoder type

§streams: HashMap<u32, StreamState>

Per-stream states (keyed by message stream ID)

§in_chunk_size: u32

Negotiated chunk size (incoming)

§out_chunk_size: u32

Negotiated chunk size (outgoing)

§window_ack_size: u32

Window acknowledgement size

§bytes_received: u64

Bytes received since last acknowledgement

§bytes_sent: u64

Bytes sent

§last_ack_sequence: u32

Last acknowledgement sequence

Implementations§

Source§

impl SessionState

Source

pub fn new(id: u64, peer_addr: SocketAddr) -> Self

Create a new session state

Source

pub fn start_handshake(&mut self)

Transition to handshaking phase

Source

pub fn complete_handshake(&mut self)

Complete handshake

Source

pub fn on_connect(&mut self, params: ConnectParams, encoder_type: EncoderType)

Handle connect command

Source

pub fn allocate_stream_id(&mut self) -> u32

Allocate a new message stream ID

Source

pub fn get_stream(&self, stream_id: u32) -> Option<&StreamState>

Get a stream by ID

Source

pub fn get_stream_mut(&mut self, stream_id: u32) -> Option<&mut StreamState>

Get a mutable stream by ID

Source

pub fn remove_stream(&mut self, stream_id: u32) -> Option<StreamState>

Remove a stream

Source

pub fn add_bytes_received(&mut self, bytes: u64) -> bool

Update bytes received and check if acknowledgement needed

Source

pub fn mark_ack_sent(&mut self)

Mark acknowledgement sent

Source

pub fn duration(&self) -> Duration

Get session duration

Source

pub fn is_active(&self) -> bool

Check if session is active

Source

pub fn close(&mut self)

Start closing the session

Source

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

Get the application name

Trait Implementations§

Source§

impl Debug for SessionState

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