pub struct Frame {
pub session_id: u32,
pub channel_id: u16,
pub seq: u8,
pub frame_type: FrameType,
pub payload: Vec<u8>,
}Expand description
Wire representation of a parsed UART protocol frame emitted by crate::FrameParser.
While Frame represents an in-memory parsed frame, encode_frame is the primary
zero-allocation serializer for transmitting byte slices over the wire.
Fields§
§session_id: u3232-bit session identifier negotiated during handshake.
channel_id: u16Logical channel identifier (Channel 0 is reserved for control).
seq: u88-bit Go-Back-N sequence number.
frame_type: FrameTypeProtocol frame type indicator.
payload: Vec<u8>Raw un-encoded payload bytes.
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn new(
session_id: u32,
channel_id: u16,
seq: u8,
frame_type: FrameType,
payload: Vec<u8>,
) -> Result<Self, FrameError>
pub fn new( session_id: u32, channel_id: u16, seq: u8, frame_type: FrameType, payload: Vec<u8>, ) -> Result<Self, FrameError>
Creates a new validated protocol frame.
§Errors
Returns FrameError::PayloadTooLarge if payload.len() > MAX_PAYLOAD_SIZE.
Sourcepub fn encode(&self) -> Result<Vec<u8>, FrameError>
pub fn encode(&self) -> Result<Vec<u8>, FrameError>
Serializes and encodes this frame with header, header checksum, and trailing CRC-32.
§Errors
Returns FrameError::PayloadTooLarge if self.payload.len() > MAX_PAYLOAD_SIZE.
Trait Implementations§
impl Eq for Frame
impl StructuralPartialEq for Frame
Auto Trait Implementations§
impl Freeze for Frame
impl RefUnwindSafe for Frame
impl Send for Frame
impl Sync for Frame
impl Unpin for Frame
impl UnsafeUnpin for Frame
impl UnwindSafe for Frame
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