pub struct Frame {
pub flags: u8,
pub size: u16,
pub reliable_index: Option<u32>,
pub sequence_index: Option<u32>,
pub order_index: Option<u32>,
pub order_channel: Option<u8>,
pub fragment_meta: Option<FragmentMeta>,
pub reliability: Reliability,
pub body: Vec<u8>,
}
Expand description
An individual data frame, these are constructed from a payload.
Fields§
§flags: u8
The flags for this frame, the first 3 bits are reserved for the reliability while the 4th bit is used to represent if this is a fragment.
size: u16
The length of the body of the frame. This is sized to 24 bits internally, so any number here must be within that range.
reliable_index: Option<u32>
The Reliable index of the frame (if reliable)
sequence_index: Option<u32>
The sequenced index of the frame (if sequenced) This is used to determine the position in frame list.
order_index: Option<u32>
The order index of the frame (if ordered) This is used to determine the position in frame list, This is different from the sequence index in that it is used more to sequence packets in a specific manner.
order_channel: Option<u8>
The order channel of the frame (if ordered) This is used to store order information for the frame.
fragment_meta: Option<FragmentMeta>
The information for fragmentation (if the frame is split into parts) This is used to determine how to reassemble the frame.
reliability: Reliability
The reliability of this frame, this is essentially used to save frames and send them back if they are lost. Otherwise, the frame is sent unreliably.
body: Vec<u8>
The body of the frame, this is the payload of the frame.
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn init() -> Self
pub fn init() -> Self
Initializes a new empty frame that is Unreliable. This is usually used to inject data into.
Sourcepub fn new(reliability: Reliability, body: Option<&[u8]>) -> Self
pub fn new(reliability: Reliability, body: Option<&[u8]>) -> Self
Initializes a new frame with the given reliability.
Sourcepub fn is_fragmented(&self) -> bool
pub fn is_fragmented(&self) -> bool
Whether or not the frame is fragmented.
Sourcepub fn is_sequenced(&self) -> bool
pub fn is_sequenced(&self) -> bool
Whether or not the frame is sequenced and reliable.