#[repr(C, packed(1))]pub struct HbtpHeader {
pub magic: u32,
pub version: u8,
pub msg_type: u8,
pub flags: u16,
pub stream_id: u32,
pub length: u32,
pub checksum: u32,
}Expand description
HBTP header - 20 bytes
Fields§
§magic: u32Magic: 0x48425450 (“HBTP”)
version: u8Protocol version
msg_type: u8Message type
flags: u16Flags (compression, priority, etc.)
stream_id: u32Multiplexed stream ID
length: u32Payload length
checksum: u32CRC32 checksum of header fields (excluding checksum itself)
Implementations§
Source§impl HbtpHeader
impl HbtpHeader
Sourcepub fn new(
version: u8,
msg_type: u8,
flags: u16,
stream_id: u32,
length: u32,
) -> Self
pub fn new( version: u8, msg_type: u8, flags: u16, stream_id: u32, length: u32, ) -> Self
Create a new HBTP header with computed checksum
Sourcepub fn compute_checksum(&self) -> u32
pub fn compute_checksum(&self) -> u32
Compute CRC32 checksum of header fields (excluding checksum)
Sourcepub fn verify_checksum(&self) -> bool
pub fn verify_checksum(&self) -> bool
Verify the checksum is correct
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<&Self, DCPError>
pub fn from_bytes(bytes: &[u8]) -> Result<&Self, DCPError>
Parse header from bytes - O(1) via pointer cast
Sourcepub fn from_bytes_verified(bytes: &[u8]) -> Result<&Self, DCPError>
pub fn from_bytes_verified(bytes: &[u8]) -> Result<&Self, DCPError>
Parse header from bytes and verify checksum
Trait Implementations§
Source§impl Clone for HbtpHeader
impl Clone for HbtpHeader
Source§fn clone(&self) -> HbtpHeader
fn clone(&self) -> HbtpHeader
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 moreimpl Copy for HbtpHeader
Source§impl Debug for HbtpHeader
impl Debug for HbtpHeader
impl Eq for HbtpHeader
Source§impl PartialEq for HbtpHeader
impl PartialEq for HbtpHeader
Source§fn eq(&self, other: &HbtpHeader) -> bool
fn eq(&self, other: &HbtpHeader) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for HbtpHeader
Auto Trait Implementations§
impl Freeze for HbtpHeader
impl RefUnwindSafe for HbtpHeader
impl Send for HbtpHeader
impl Sync for HbtpHeader
impl Unpin for HbtpHeader
impl UnsafeUnpin for HbtpHeader
impl UnwindSafe for HbtpHeader
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