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: u64Unique session ID
peer_addr: SocketAddrRemote peer address
phase: SessionPhaseCurrent phase
connected_at: InstantConnection start time
handshake_completed_at: Option<Instant>Time when handshake completed
connect_params: Option<ConnectParams>Connect parameters (after connect command)
encoder_type: EncoderTypeDetected encoder type
streams: HashMap<u32, StreamState>Per-stream states (keyed by message stream ID)
in_chunk_size: u32Negotiated chunk size (incoming)
out_chunk_size: u32Negotiated chunk size (outgoing)
window_ack_size: u32Window acknowledgement size
bytes_received: u64Bytes received since last acknowledgement
bytes_sent: u64Bytes sent
last_ack_sequence: u32Last acknowledgement sequence
Implementations§
Source§impl SessionState
impl SessionState
Sourcepub fn new(id: u64, peer_addr: SocketAddr) -> Self
pub fn new(id: u64, peer_addr: SocketAddr) -> Self
Create a new session state
Sourcepub fn start_handshake(&mut self)
pub fn start_handshake(&mut self)
Transition to handshaking phase
Sourcepub fn complete_handshake(&mut self)
pub fn complete_handshake(&mut self)
Complete handshake
Sourcepub fn on_connect(&mut self, params: ConnectParams, encoder_type: EncoderType)
pub fn on_connect(&mut self, params: ConnectParams, encoder_type: EncoderType)
Handle connect command
Sourcepub fn allocate_stream_id(&mut self) -> u32
pub fn allocate_stream_id(&mut self) -> u32
Allocate a new message stream ID
Sourcepub fn get_stream(&self, stream_id: u32) -> Option<&StreamState>
pub fn get_stream(&self, stream_id: u32) -> Option<&StreamState>
Get a stream by ID
Sourcepub fn get_stream_mut(&mut self, stream_id: u32) -> Option<&mut StreamState>
pub fn get_stream_mut(&mut self, stream_id: u32) -> Option<&mut StreamState>
Get a mutable stream by ID
Sourcepub fn remove_stream(&mut self, stream_id: u32) -> Option<StreamState>
pub fn remove_stream(&mut self, stream_id: u32) -> Option<StreamState>
Remove a stream
Sourcepub fn add_bytes_received(&mut self, bytes: u64) -> bool
pub fn add_bytes_received(&mut self, bytes: u64) -> bool
Update bytes received and check if acknowledgement needed
Sourcepub fn mark_ack_sent(&mut self)
pub fn mark_ack_sent(&mut self)
Mark acknowledgement sent
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SessionState
impl RefUnwindSafe for SessionState
impl Send for SessionState
impl Sync for SessionState
impl Unpin for SessionState
impl UnwindSafe for SessionState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more