pub struct MobileProtocolHeader {
pub magic: u8,
pub version: u8,
pub msg_type: u8,
pub flags: u8,
pub headcrc16: u16,
pub datacrc: u16,
pub seq_id: u16,
pub timeout: u16,
pub body_length: u32,
}Expand description
Mobile Protocol Header (16 bytes)
Compact header designed for mobile clients with bandwidth constraints.
Fields§
§magic: u8Magic number: 0xDF
version: u8Protocol version
msg_type: u8Message type: REQ(1), RSP(2), NOTIFY(3), SYSRSP(4)
flags: u8Flags: bit0=compressed, bit1=encrypted, bit2=fragment
headcrc16: u16Header CRC16 (truncating addition checksum)
datacrc: u16Data CRC16 (lower 16 bits of CRC32)
seq_id: u16Sequence ID (16-bit, wraps around)
timeout: u16Timeout in seconds (not milliseconds!)
body_length: u32Body length in bytes
Implementations§
Source§impl MobileProtocolHeader
impl MobileProtocolHeader
Sourcepub fn is_compressed(&self) -> bool
pub fn is_compressed(&self) -> bool
Check if data is compressed
Sourcepub fn is_encrypted(&self) -> bool
pub fn is_encrypted(&self) -> bool
Check if data is encrypted
Sourcepub fn is_fragment(&self) -> bool
pub fn is_fragment(&self) -> bool
Check if this is a fragment (mobile-specific)
Sourcepub fn set_compressed(&mut self, compressed: bool)
pub fn set_compressed(&mut self, compressed: bool)
Set compressed flag
Sourcepub fn set_encrypted(&mut self, encrypted: bool)
pub fn set_encrypted(&mut self, encrypted: bool)
Set encrypted flag
Sourcepub fn set_fragment(&mut self, is_fragment: bool)
pub fn set_fragment(&mut self, is_fragment: bool)
Set fragment flag
Sourcepub fn calculate_datacrc(data: &[u8]) -> u16
pub fn calculate_datacrc(data: &[u8]) -> u16
Calculate data CRC16 for body
Sourcepub fn verify_datacrc(&self, data: &[u8]) -> bool
pub fn verify_datacrc(&self, data: &[u8]) -> bool
Verify data CRC
Trait Implementations§
Source§impl Clone for MobileProtocolHeader
impl Clone for MobileProtocolHeader
Source§fn clone(&self) -> MobileProtocolHeader
fn clone(&self) -> MobileProtocolHeader
Returns a duplicate of the value. Read more
1.0.0 · 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 MobileProtocolHeader
impl RefUnwindSafe for MobileProtocolHeader
impl Send for MobileProtocolHeader
impl Sync for MobileProtocolHeader
impl Unpin for MobileProtocolHeader
impl UnwindSafe for MobileProtocolHeader
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