Struct FrameHeader
pub(super) struct FrameHeader {
pub(super) crc: u32,
pub(super) len: u64,
}Available on crate feature
alloc only.Expand description
12-byte journal frame header: crc32_be(4) || length_be(8).
The CRC covers length_be || payload. The length is a u64, so it can
address any payload a slice can hold (usize is at most 64 bits), and no
frame can ever overflow its length field.
Fields§
§crc: u32§len: u64Implementations§
§impl FrameHeader
impl FrameHeader
pub(super) const LEN: usize = 12usize
pub(super) fn build(payload: &[u8]) -> Self
pub(super) fn build(payload: &[u8]) -> Self
Builds a header for the given payload by computing its CRC.
pub(super) fn decode(bytes: &[u8]) -> Self
pub(super) fn decode(bytes: &[u8]) -> Self
Decodes a LEN-byte header. Caller must ensure
bytes.len() == LEN.
pub(super) fn verify_with_crc(expected_crc: u32, payload: &[u8]) -> bool
pub(super) fn verify_with_crc(expected_crc: u32, payload: &[u8]) -> bool
Returns true if the payload’s CRC matches expected_crc.
pub(super) fn encode_to_vec(&self, buf: &mut Vec<u8>)
Auto Trait Implementations§
impl Freeze for FrameHeader
impl RefUnwindSafe for FrameHeader
impl Send for FrameHeader
impl Sync for FrameHeader
impl Unpin for FrameHeader
impl UnwindSafe for FrameHeader
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