#[repr(C)]pub struct CrushHeader {
pub magic: [u8; 4],
pub original_size: u64,
pub flags: u8,
pub reserved: [u8; 3],
}Expand description
Crush compressed file header (16 bytes, little-endian)
Format:
Offset | Size | Field
-------|------|-------
0 | 4 | magic_number ([u8; 4])
4 | 8 | original_size (u64, little-endian)
12 | 1 | flags (u8)
13 | 3 | reserved (padding to 16 bytes)Flags byte (bit fields):
- Bit 0: Has CRC32 (if set, CRC32 follows header)
- Bit 1: Has metadata (if set, variable-length metadata follows header)
- Bits 2-7: Reserved for future use
Fields§
§magic: [u8; 4]Magic number identifying the compression plugin
original_size: u64Original uncompressed size in bytes
flags: u8Feature flags (see struct documentation)
reserved: [u8; 3]Reserved bytes for future extensions (must be zero)
Implementations§
Source§impl CrushHeader
impl CrushHeader
Sourcepub const MAGIC_PREFIX: [u8; 2]
pub const MAGIC_PREFIX: [u8; 2]
Crush file format identifier prefix (“CR” = 0x43 0x52)
Sourcepub fn new(magic: [u8; 4], original_size: u64) -> Self
pub fn new(magic: [u8; 4], original_size: u64) -> Self
Create a new header with the given plugin magic number and original size
Sourcepub fn with_crc32(self) -> Self
pub fn with_crc32(self) -> Self
Create a header with CRC32 flag set
Sourcepub fn with_metadata(self) -> Self
pub fn with_metadata(self) -> Self
Create a header with metadata flag set
Sourcepub fn has_valid_prefix(&self) -> bool
pub fn has_valid_prefix(&self) -> bool
Check if this header has a valid Crush magic number prefix
Sourcepub fn has_valid_version(&self) -> bool
pub fn has_valid_version(&self) -> bool
Check if this header has a valid Crush format version
Sourcepub fn has_metadata(&self) -> bool
pub fn has_metadata(&self) -> bool
Check if metadata flag is set
Sourcepub fn from_bytes(bytes: &[u8; 16]) -> Result<Self>
pub fn from_bytes(bytes: &[u8; 16]) -> Result<Self>
Deserialize header from bytes
§Errors
Returns an error if:
- The magic number prefix is not valid (not “CR”)
- The version byte is unsupported
Trait Implementations§
Source§impl Clone for CrushHeader
impl Clone for CrushHeader
Source§fn clone(&self) -> CrushHeader
fn clone(&self) -> CrushHeader
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 moreSource§impl Debug for CrushHeader
impl Debug for CrushHeader
Source§impl PartialEq for CrushHeader
impl PartialEq for CrushHeader
impl Copy for CrushHeader
impl Eq for CrushHeader
impl StructuralPartialEq for CrushHeader
Auto Trait Implementations§
impl Freeze for CrushHeader
impl RefUnwindSafe for CrushHeader
impl Send for CrushHeader
impl Sync for CrushHeader
impl Unpin for CrushHeader
impl UnsafeUnpin for CrushHeader
impl UnwindSafe for CrushHeader
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