Skip to main content

ProtocolSession

Struct ProtocolSession 

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

Protocol session

Implementations§

Source§

impl ProtocolSession

Source

pub fn new_server(cipher_suite: CipherSuite) -> Self

Create a new server-side session

Source

pub fn new_client(cipher_suite: CipherSuite) -> Self

Create a new client-side session

Source

pub fn local_session_id(&self) -> &SessionIdBytes

Get local session ID

Source

pub fn remote_session_id(&self) -> Option<&SessionIdBytes>

Get remote session ID

Source

pub fn state(&self) -> ProtocolState

Get current state

Source

pub fn set_state(&mut self, state: ProtocolState)

Set state

Source

pub fn set_remote_session_id(&mut self, id: SessionIdBytes)

Set remote session ID

Source

pub fn set_tls_auth(&mut self, key: HmacAuth)

Enable tls-auth

Source

pub fn set_cipher_suite(&mut self, cipher_suite: CipherSuite)

Update the cipher suite (e.g., after NCP cipher negotiation)

Source

pub fn process_packet(&mut self, data: &[u8]) -> Result<ProcessedPacket>

Process incoming packet

Source

pub fn create_hard_reset_response(&mut self) -> Result<Bytes>

Create a hard reset response packet

Source

pub fn create_control_packets(&mut self, tls_data: Bytes) -> Result<Vec<Bytes>>

Create control packets with TLS data, splitting across multiple packets if the data exceeds the maximum control channel payload size. This prevents oversized UDP datagrams that would require IP fragmentation.

Source

pub fn create_control_packet(&mut self, tls_data: Bytes) -> Result<Bytes>

Create a control packet with TLS data (convenience for single packet)

Source

pub fn create_ack_packet(&mut self) -> Option<Bytes>

Create an ACK packet

Source

pub fn install_keys(&mut self, key_material: &KeyMaterial, is_server: bool)

Install data channel keys

Source

pub fn encrypt_data(&mut self, data: &[u8]) -> Result<Bytes>

Encrypt data for transmission

Source

pub fn get_retransmits(&mut self) -> Vec<Bytes>

Get packets needing retransmission

Source

pub fn should_send_ack(&self) -> bool

Check if we should send an ACK

Source

pub fn next_timeout(&self) -> Option<Duration>

Get next timeout

Source

pub fn is_established(&self) -> bool

Check if session is established

Source

pub fn duration(&self) -> Duration

Get session duration

Source

pub fn idle_time(&self) -> Duration

Get idle time

Source

pub fn rotate_key(&mut self)

Rotate to next key ID (for rekeying)

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