pub struct ConstrainedHeader {
pub connection_id: ConnectionId,
pub seq: SequenceNumber,
pub ack: SequenceNumber,
pub flags: PacketFlags,
}Expand description
Constrained protocol packet header
A compact 5-byte header containing all information needed for reliable delivery.
Fields§
§connection_id: ConnectionIdConnection identifier (2 bytes)
seq: SequenceNumberSequence number for this packet (1 byte)
ack: SequenceNumberAcknowledgment number (cumulative) (1 byte)
flags: PacketFlagsPacket flags (1 byte)
Implementations§
Source§impl ConstrainedHeader
impl ConstrainedHeader
Sourcepub const fn new(
connection_id: ConnectionId,
seq: SequenceNumber,
ack: SequenceNumber,
flags: PacketFlags,
) -> Self
pub const fn new( connection_id: ConnectionId, seq: SequenceNumber, ack: SequenceNumber, flags: PacketFlags, ) -> Self
Create a new header with the specified fields
Sourcepub fn syn(connection_id: ConnectionId) -> Self
pub fn syn(connection_id: ConnectionId) -> Self
Create a SYN header for connection initiation
Sourcepub fn syn_ack(connection_id: ConnectionId, ack: SequenceNumber) -> Self
pub fn syn_ack(connection_id: ConnectionId, ack: SequenceNumber) -> Self
Create a SYN-ACK header for connection response
Sourcepub fn ack(
connection_id: ConnectionId,
seq: SequenceNumber,
ack: SequenceNumber,
) -> Self
pub fn ack( connection_id: ConnectionId, seq: SequenceNumber, ack: SequenceNumber, ) -> Self
Create an ACK-only header
Sourcepub fn data(
connection_id: ConnectionId,
seq: SequenceNumber,
ack: SequenceNumber,
) -> Self
pub fn data( connection_id: ConnectionId, seq: SequenceNumber, ack: SequenceNumber, ) -> Self
Create a DATA header
Sourcepub fn fin(
connection_id: ConnectionId,
seq: SequenceNumber,
ack: SequenceNumber,
) -> Self
pub fn fin( connection_id: ConnectionId, seq: SequenceNumber, ack: SequenceNumber, ) -> Self
Create a FIN header for connection close
Sourcepub fn reset(connection_id: ConnectionId) -> Self
pub fn reset(connection_id: ConnectionId) -> Self
Create a RST header for connection reset
Sourcepub fn ping(connection_id: ConnectionId, seq: SequenceNumber) -> Self
pub fn ping(connection_id: ConnectionId, seq: SequenceNumber) -> Self
Create a PING header for keep-alive
Sourcepub fn pong(connection_id: ConnectionId, ack: SequenceNumber) -> Self
pub fn pong(connection_id: ConnectionId, ack: SequenceNumber) -> Self
Create a PONG header in response to ping
Sourcepub fn to_bytes(&self) -> [u8; 5]
pub fn to_bytes(&self) -> [u8; 5]
Serialize header to bytes
Returns a 5-byte array containing the serialized header.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, ConstrainedError>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, ConstrainedError>
Deserialize header from bytes
Returns an error if the slice is too short.
Sourcepub const fn is_syn_ack(&self) -> bool
pub const fn is_syn_ack(&self) -> bool
Check if this is a SYN-ACK packet
Trait Implementations§
Source§impl Clone for ConstrainedHeader
impl Clone for ConstrainedHeader
Source§fn clone(&self) -> ConstrainedHeader
fn clone(&self) -> ConstrainedHeader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ConstrainedHeader
Source§impl Debug for ConstrainedHeader
impl Debug for ConstrainedHeader
Source§impl Display for ConstrainedHeader
impl Display for ConstrainedHeader
impl Eq for ConstrainedHeader
Source§impl PartialEq for ConstrainedHeader
impl PartialEq for ConstrainedHeader
impl StructuralPartialEq for ConstrainedHeader
Auto Trait Implementations§
impl Freeze for ConstrainedHeader
impl RefUnwindSafe for ConstrainedHeader
impl Send for ConstrainedHeader
impl Sync for ConstrainedHeader
impl Unpin for ConstrainedHeader
impl UnsafeUnpin for ConstrainedHeader
impl UnwindSafe for ConstrainedHeader
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.