ConnectionState

Struct ConnectionState 

Source
pub struct ConnectionState {
Show 15 fields pub session_id: SessionId, pub phase: ConnectionPhase, pub remote_endpoint: SocketAddr, pub last_received: Instant, pub epoch: u32, pub send_nonce: u64, pub recv_nonce_window: NonceWindow, pub rtt: RttEstimator, pub timestamps: TimestampTracker, pub pacer: FramePacer, pub retransmit: RetransmitController, pub migration: MigrationState, pub local_state_version: u64, pub remote_state_version: u64, pub acked_state_version: u64,
}
Available on crate feature transport only.
Expand description

Full connection state as specified in 2-TRANSPORT.md.

Fields§

§session_id: SessionId

Session identifier from handshake.

§phase: ConnectionPhase

Current connection phase.

§remote_endpoint: SocketAddr

Remote peer address (may change during migration).

§last_received: Instant

When we last received an authenticated frame.

§epoch: u32

Current epoch (increments on rekey).

§send_nonce: u64

Outbound nonce counter (monotonically increasing).

§recv_nonce_window: NonceWindow

Inbound anti-replay window.

§rtt: RttEstimator

RTT estimation.

§timestamps: TimestampTracker

Timestamp tracking for RTT measurement.

§pacer: FramePacer

Frame pacing.

§retransmit: RetransmitController

Retransmission control.

§migration: MigrationState

Migration state.

§local_state_version: u64

Highest state version we’ve sent.

§remote_state_version: u64

Highest state version we’ve acknowledged from peer.

§acked_state_version: u64

Highest state version the peer has acknowledged from us.

Implementations§

Source§

impl ConnectionState

Source

pub fn new(session_id: SessionId, remote_endpoint: SocketAddr) -> Self

Create a new connection state for an established session.

Source

pub fn handshaking(remote_endpoint: SocketAddr) -> Self

Create a connection state in handshaking phase.

Source

pub fn next_send_nonce(&mut self) -> u64

Get the next nonce for sending and increment the counter.

Source

pub fn check_recv_nonce(&mut self, nonce: u64) -> bool

Check if a received nonce is valid (not replayed).

Source

pub fn on_authenticated_frame(&mut self, from: SocketAddr)

Update state after receiving an authenticated frame.

Source

pub fn is_alive(&self) -> bool

Check if the connection is still alive.

Source

pub fn is_failed(&self) -> bool

Check if the connection has failed.

Source

pub fn has_unacked_data(&self) -> bool

Check if there’s unacknowledged data.

Source

pub fn on_ack(&mut self, acked_version: u64)

Update the acked state version.

Source

pub fn close(&mut self)

Transition to closed state.

Source

pub fn mark_closed(&mut self)

Mark as fully closed.

Source

pub fn mark_failed(&mut self)

Mark as failed.

Source

pub fn complete_handshake(&mut self, session_id: SessionId)

Complete handshake and transition to established.

Source

pub fn on_rekey(&mut self)

Increment epoch (on rekey).

Trait Implementations§

Source§

impl Debug for ConnectionState

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