morpheus_core::iso::adapter

Struct ChunkedBlockIo

Source
pub struct ChunkedBlockIo<F>
where F: FnMut(u64, &mut [u8]) -> Result<(), IsoError>,
{ ctx: IsoReadContext, read_fn: F, block_size: u32, total_sectors: u64, }
Expand description

Block I/O adapter for chunked ISO storage

Implements a virtual block device over chunked partitions.

Fields§

§ctx: IsoReadContext

ISO read context (chunk locations)

§read_fn: F

Callback to read from underlying disk

§block_size: u32

Cached block size

§total_sectors: u64

Total sectors in virtual device

Implementations§

Source§

impl<F> ChunkedBlockIo<F>
where F: FnMut(u64, &mut [u8]) -> Result<(), IsoError>,

Source

pub fn new(ctx: IsoReadContext, read_fn: F) -> Self

Create a new chunked block I/O adapter

§Arguments
  • ctx - ISO read context with chunk partition info
  • read_fn - Callback to read from disk: fn(lba, buffer) -> Result
Source

pub fn total_size(&self) -> u64

Get total size in bytes

Source

pub fn total_sectors(&self) -> u64

Get total number of sectors

Source

fn find_chunk_for_lba(&self, virtual_lba: u64) -> Option<(usize, u64)>

Find which chunk contains a given virtual LBA

Source

pub fn read_sector( &mut self, virtual_lba: u64, buffer: &mut [u8], ) -> Result<(), IsoError>

Read a single sector

Source

pub fn read_sectors( &mut self, start_lba: u64, buffer: &mut [u8], ) -> Result<usize, IsoError>

Read multiple sectors

Trait Implementations§

Source§

impl<F> VirtualBlockIo for ChunkedBlockIo<F>
where F: FnMut(u64, &mut [u8]) -> Result<(), IsoError>,

Source§

fn read_blocks(&mut self, lba: u64, buffer: &mut [u8]) -> Result<(), IsoError>

Read blocks starting at the given LBA
Source§

fn block_size(&self) -> u32

Get block size
Source§

fn num_blocks(&self) -> u64

Get total number of blocks

Auto Trait Implementations§

§

impl<F> Freeze for ChunkedBlockIo<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for ChunkedBlockIo<F>
where F: RefUnwindSafe,

§

impl<F> Send for ChunkedBlockIo<F>
where F: Send,

§

impl<F> Sync for ChunkedBlockIo<F>
where F: Sync,

§

impl<F> Unpin for ChunkedBlockIo<F>
where F: Unpin,

§

impl<F> UnwindSafe for ChunkedBlockIo<F>
where F: UnwindSafe,

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 = Infallible

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.