Skip to main content

VolumeReader

Struct VolumeReader 

pub struct VolumeReader<'a, R, M> {
    source: &'a R,
    map: M,
    block_size: u32,
    data_offset: u32,
    leb_size: u32,
    size: u64,
}
Expand description

Reader over the data of a volume in a UBI image.

Returned by super::Image::volume. Byte n of the volume is in logical eraseblock n / leb_size. A read goes to the blocks of the image that contain those logical eraseblocks, without a buffer. Like in the kernel, logical eraseblocks without a block read as 0xFF.

M is the block map, see super::Image::volume.

Fields§

§source: &'a R§map: M§block_size: u32§data_offset: u32§leb_size: u32§size: u64

Implementations§

§

impl<'a, R, M: AsRef<[u32]>> VolumeReader<'a, R, M>

pub(crate) const fn new( source: &'a R, map: M, block_size: u32, data_offset: u32, leb_size: u32, size: u64, ) -> Self

pub const fn leb_size(&self) -> u32

Returns the bytes of data in a logical eraseblock of the volume. It excludes the padding that the alignment of the volume leaves.

pub fn block(&self, lnum: u32) -> Option<u32>

Returns the index of the block in the image that contains logical eraseblock lnum, or None if there is none.

pub fn into_map(self) -> M

Returns the block map.

Trait Implementations§

§

impl<R, M> Debug for VolumeReader<'_, R, M>

§

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

Formats the value using the given formatter. Read more
§

impl<R: ReadAt, M: AsRef<[u32]>> ReadAt for VolumeReader<'_, R, M>

§

type Error = VolumeReadError<<R as ReadAt>::Error>

Error of a failed read.
§

fn read_exact_at(&self, offset: u64, buf: &mut [u8]) -> Result<(), Self::Error>

Fills buf with the bytes at offset. Read more
§

fn size(&self) -> Result<u64, Self::Error>

Returns the size of the source in bytes. Read more

Auto Trait Implementations§

§

impl<'a, R, M> Freeze for VolumeReader<'a, R, M>
where &'a R: Freeze, M: Freeze,

§

impl<'a, R, M> RefUnwindSafe for VolumeReader<'a, R, M>

§

impl<'a, R, M> Send for VolumeReader<'a, R, M>
where &'a R: Send, M: Send,

§

impl<'a, R, M> Sync for VolumeReader<'a, R, M>
where &'a R: Sync, M: Sync,

§

impl<'a, R, M> Unpin for VolumeReader<'a, R, M>
where &'a R: Unpin, M: Unpin,

§

impl<'a, R, M> UnsafeUnpin for VolumeReader<'a, R, M>

§

impl<'a, R, M> UnwindSafe for VolumeReader<'a, R, M>

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> 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, 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.