Struct ImageBlock
pub struct ImageBlock<'a> {
index: u32,
ec: Option<EcHeader>,
vid: Option<VidHeader>,
bytes: &'a [u8],
}Expand description
Erase block of a UBI image.
Returned by ImageReader::next_block.
Fields§
§index: u32§ec: Option<EcHeader>§vid: Option<VidHeader>§bytes: &'a [u8]Implementations§
§impl<'a> ImageBlock<'a>
impl<'a> ImageBlock<'a>
pub const fn ec_header(&self) -> Option<&EcHeader>
pub const fn ec_header(&self) -> Option<&EcHeader>
Returns the erase counter header, or None for an erased block.
pub const fn vid_header(&self) -> Option<&VidHeader>
pub const fn vid_header(&self) -> Option<&VidHeader>
Returns the volume identifier header, or None if the block doesn’t
contain data.
pub fn leb_size(&self) -> Option<u32>
pub fn leb_size(&self) -> Option<u32>
Returns the size of a logical eraseblock, or None for an erased
block.
pub fn data(&self) -> &'a [u8] ⓘ
pub fn data(&self) -> &'a [u8] ⓘ
Returns the data of the logical eraseblock, or an empty slice if the block doesn’t contain data.
For a static volume or a copy that wear leveling made, it’s exactly
VidHeader::data_size bytes. Otherwise it excludes the padding that
the volume’s alignment leaves at the end of the block.
ImageBlock::check_data_crc checks the data of a static volume or a
copy.
pub fn check_data_crc(&self) -> Result<(), FormatError>
pub fn check_data_crc(&self) -> Result<(), FormatError>
Checks the data against the CRC in the VID header.
Only static volumes and copies that wear leveling made store a CRC.
For other blocks it does nothing. The kernel rejects reads of static
data with a wrong CRC. Newer kernels skip the check if
super::VolumeRecord::skip_crc_check is set. The kernel uses an
older copy of a block instead of a damaged copy.
§Errors
Returns FormatError::Crc if the data doesn’t match the CRC.
Trait Implementations§
§impl<'a> Clone for ImageBlock<'a>
impl<'a> Clone for ImageBlock<'a>
§fn clone(&self) -> ImageBlock<'a>
fn clone(&self) -> ImageBlock<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more