Struct open_protocol::header::Header
[−]
[src]
pub struct Header(_);
Represents the frame header.
Example
use open_protocol::header::{Header, SDK_SOF}; let header = Header::build() .sof(SDK_SOF) .length(24) .version(0) .session_id(1) .ack(false) .enc(1) .seq(4) .crc() .unwrap(); // Verify the header header.verify(); // Get frame length let frame_length = header.length(); frame_length == 24;
Methods
impl Header
[src]
fn build() -> HeaderBuilder
Create a HeaderBuiler for building a frame header.
fn sof(&self) -> u8
Starting byte. Fixed to be 0xAA.
8 bits.
fn length(&self) -> usize
The length of the frame.
10 bits.
fn version(&self) -> u8
The version of the frame header. Always zero.
6 bits.
fn session_id(&self) -> u8
Ths session id of this frame.
5 bits.
fn is_ack(&self) -> bool
The type of this frame. ture
means the frame is a ack frame,
false
means the frame is a cmd frame.
1 bit
fn reserved0(&self) -> u8
Always set to zero.
2 bits.
fn padding(&self) -> u8
Padding data used by encryption logic.
5 bits.
fn enc(&self) -> u8
Encryption type. 0 means no encryption, 1 means ase encryption.
3 bits.
fn reserved1(&self) -> u32
Always set to zero.
24 bits.
fn seq(&self) -> u16
The frame sequence number.
16 bits.
fn crc(&self) -> u16
CRC16 of the header of the frame.
16 bits.
fn verify(&self) -> bool
Check whether the data is a valid frame header.
Trait Implementations
impl Debug for Header
[src]
impl Clone for Header
[src]
fn clone(&self) -> Header
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more