Skip to main content

ImageBlock

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>

pub const fn index(&self) -> u32

Returns the index of the block in the image.

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>

Returns the volume identifier header, or None if the block doesn’t contain data.

pub fn leb_size(&self) -> Option<u32>

Returns the size of a logical eraseblock, or None for an erased block.

pub const fn bytes(&self) -> &'a [u8] ⓘ

Returns all bytes of the block.

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>

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>

§

fn clone(&self) -> ImageBlock<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<'a> Copy for ImageBlock<'a>

§

impl Debug for ImageBlock<'_>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ImageBlock<'a>

§

impl<'a> RefUnwindSafe for ImageBlock<'a>

§

impl<'a> Send for ImageBlock<'a>

§

impl<'a> Sync for ImageBlock<'a>

§

impl<'a> Unpin for ImageBlock<'a>

§

impl<'a> UnsafeUnpin for ImageBlock<'a>

§

impl<'a> UnwindSafe for ImageBlock<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.