pub struct BcpHeader {
pub version_major: u8,
pub version_minor: u8,
pub flags: HeaderFlags,
}Expand description
BCP file header — the first 8 bytes of every payload.
┌────────┬─────────┬──────────────────────────────────┐
│ Offset │ Size │ Description │
├────────┼─────────┼──────────────────────────────────┤
│ 0x00 │ 4 bytes │ Magic: "BCP\0" (0x42435000) │
│ 0x04 │ 1 byte │ Version major │
│ 0x05 │ 1 byte │ Version minor │
│ 0x06 │ 1 byte │ Flags │
│ 0x07 │ 1 byte │ Reserved (0x00) │
└────────┴─────────┴──────────────────────────────────┘Fields§
§version_major: u8§version_minor: u8§flags: HeaderFlagsImplementations§
Source§impl BcpHeader
impl BcpHeader
Sourcepub fn new(flags: HeaderFlags) -> Self
pub fn new(flags: HeaderFlags) -> Self
Create a new header with the current version and the given flags.
Sourcepub fn write_to(&self, buf: &mut [u8]) -> Result<(), WireError>
pub fn write_to(&self, buf: &mut [u8]) -> Result<(), WireError>
Write the 8-byte header into the provided buffer.
§Errors
Returns WireError::UnexpectedEof if buf is shorter than
HEADER_SIZE (8 bytes).
Sourcepub fn read_from(buf: &[u8]) -> Result<Self, WireError>
pub fn read_from(buf: &[u8]) -> Result<Self, WireError>
Parse a header from the first 8 bytes of the provided buffer.
§Errors
WireError::UnexpectedEofif buffer is too short.WireError::InvalidMagicif the magic number doesn’t match.WireError::UnsupportedVersionif the major version is unknown.WireError::ReservedNonZeroif the reserved byte is not 0x00.
Trait Implementations§
impl Eq for BcpHeader
impl StructuralPartialEq for BcpHeader
Auto Trait Implementations§
impl Freeze for BcpHeader
impl RefUnwindSafe for BcpHeader
impl Send for BcpHeader
impl Sync for BcpHeader
impl Unpin for BcpHeader
impl UnsafeUnpin for BcpHeader
impl UnwindSafe for BcpHeader
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