pub struct ConstrainedConnection { /* private fields */ }Expand description
A constrained protocol connection
Manages the full lifecycle of a connection including:
- State machine transitions
- Reliable delivery via ARQ
- Packet serialization/deserialization
- Keep-alive management
Implementations§
Source§impl ConstrainedConnection
impl ConstrainedConnection
Sourcepub fn new_outbound(
connection_id: ConnectionId,
remote_addr: SocketAddr,
) -> Self
pub fn new_outbound( connection_id: ConnectionId, remote_addr: SocketAddr, ) -> Self
Create a new outbound connection (initiator)
Sourcepub fn new_outbound_with_config(
connection_id: ConnectionId,
remote_addr: SocketAddr,
config: ConnectionConfig,
) -> Self
pub fn new_outbound_with_config( connection_id: ConnectionId, remote_addr: SocketAddr, config: ConnectionConfig, ) -> Self
Create a new outbound connection with config
Sourcepub fn new_inbound(connection_id: ConnectionId, remote_addr: SocketAddr) -> Self
pub fn new_inbound(connection_id: ConnectionId, remote_addr: SocketAddr) -> Self
Create a new inbound connection (responder)
Sourcepub fn new_inbound_with_config(
connection_id: ConnectionId,
remote_addr: SocketAddr,
config: ConnectionConfig,
) -> Self
pub fn new_inbound_with_config( connection_id: ConnectionId, remote_addr: SocketAddr, config: ConnectionConfig, ) -> Self
Create a new inbound connection with config
Sourcepub fn connection_id(&self) -> ConnectionId
pub fn connection_id(&self) -> ConnectionId
Get the connection ID
Sourcepub fn remote_addr(&self) -> SocketAddr
pub fn remote_addr(&self) -> SocketAddr
Get the remote address
Sourcepub fn state(&self) -> ConnectionState
pub fn state(&self) -> ConnectionState
Get current connection state
Sourcepub fn is_established(&self) -> bool
pub fn is_established(&self) -> bool
Check if connection is established
Sourcepub fn initiate(&mut self) -> Result<ConstrainedPacket, ConstrainedError>
pub fn initiate(&mut self) -> Result<ConstrainedPacket, ConstrainedError>
Initiate connection (for outbound connections)
Returns a SYN packet to transmit.
Sourcepub fn accept(
&mut self,
syn_seq: SequenceNumber,
) -> Result<ConstrainedPacket, ConstrainedError>
pub fn accept( &mut self, syn_seq: SequenceNumber, ) -> Result<ConstrainedPacket, ConstrainedError>
Accept a connection (for inbound connections after receiving SYN)
Returns a SYN-ACK packet to transmit.
Sourcepub fn send(&mut self, data: &[u8]) -> Result<(), ConstrainedError>
pub fn send(&mut self, data: &[u8]) -> Result<(), ConstrainedError>
Send data
Data may be fragmented if larger than MSS.
Sourcepub fn close(&mut self) -> Result<ConstrainedPacket, ConstrainedError>
pub fn close(&mut self) -> Result<ConstrainedPacket, ConstrainedError>
Close the connection gracefully
Sourcepub fn reset(&mut self) -> ConstrainedPacket
pub fn reset(&mut self) -> ConstrainedPacket
Reset the connection immediately
Sourcepub fn process_packet(
&mut self,
packet: &ConstrainedPacket,
) -> Result<(), ConstrainedError>
pub fn process_packet( &mut self, packet: &ConstrainedPacket, ) -> Result<(), ConstrainedError>
Process an incoming packet
Sourcepub fn poll(&mut self) -> Vec<ConstrainedPacket>
pub fn poll(&mut self) -> Vec<ConstrainedPacket>
Poll the connection for timeout handling and retransmissions
Returns packets that need to be (re)transmitted.
Sourcepub fn next_event(&mut self) -> Option<ConnectionEvent>
pub fn next_event(&mut self) -> Option<ConnectionEvent>
Get next pending event
Sourcepub fn stats(&self) -> ConnectionStats
pub fn stats(&self) -> ConnectionStats
Get connection statistics