pub struct ConstrainedPacket {
pub header: ConstrainedHeader,
pub payload: Vec<u8>,
}Expand description
A complete packet with header and optional payload
Fields§
§header: ConstrainedHeaderPacket header
payload: Vec<u8>Packet payload (empty for control packets)
Implementations§
Source§impl ConstrainedPacket
impl ConstrainedPacket
Sourcepub fn new(header: ConstrainedHeader, payload: Vec<u8>) -> Self
pub fn new(header: ConstrainedHeader, payload: Vec<u8>) -> Self
Create a new packet with header and payload
Sourcepub fn control(header: ConstrainedHeader) -> Self
pub fn control(header: ConstrainedHeader) -> Self
Create a control packet (no payload)
Sourcepub fn data(
connection_id: ConnectionId,
seq: SequenceNumber,
ack: SequenceNumber,
payload: Vec<u8>,
) -> Self
pub fn data( connection_id: ConnectionId, seq: SequenceNumber, ack: SequenceNumber, payload: Vec<u8>, ) -> Self
Create a data packet
Sourcepub fn total_size(&self) -> usize
pub fn total_size(&self) -> usize
Total size of the packet (header + payload)
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, ConstrainedError>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, ConstrainedError>
Deserialize a packet from bytes
Sourcepub fn has_payload(&self) -> bool
pub fn has_payload(&self) -> bool
Check if this packet has a payload
Trait Implementations§
Source§impl Clone for ConstrainedPacket
impl Clone for ConstrainedPacket
Source§fn clone(&self) -> ConstrainedPacket
fn clone(&self) -> ConstrainedPacket
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ConstrainedPacket
impl RefUnwindSafe for ConstrainedPacket
impl Send for ConstrainedPacket
impl Sync for ConstrainedPacket
impl Unpin for ConstrainedPacket
impl UnsafeUnpin for ConstrainedPacket
impl UnwindSafe for ConstrainedPacket
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