morpheus_core::iso::reader

Struct ChunkReader

Source
pub struct ChunkReader {
    chunks: ChunkSet,
    position: u64,
    total_size: u64,
    chunk_size: u64,
    current_chunk_cache: usize,
}
Expand description

Chunk reader for streaming ISO data

Fields§

§chunks: ChunkSet

Chunk information

§position: u64

Current read position (for sequential reads)

§total_size: u64

Total ISO size

§chunk_size: u64

Chunk size used during write

§current_chunk_cache: usize

Cached current chunk index (optimization)

Implementations§

Source§

impl ChunkReader

Source

pub fn from_manifest(manifest: &IsoManifest) -> Result<Self, IsoError>

Create a reader from a manifest

Source

pub fn from_chunks(chunks: ChunkSet, chunk_size: u64) -> Self

Create a reader from a chunk set

Source

pub fn total_size(&self) -> u64

Get total ISO size

Source

pub fn position(&self) -> u64

Get current read position

Source

pub fn num_chunks(&self) -> usize

Get number of chunks

Source

pub fn seek(&mut self, position: u64) -> Result<(), IsoError>

Seek to a position

Source

pub fn remaining(&self) -> u64

Get remaining bytes from current position

Source

pub fn is_eof(&self) -> bool

Check if at end of ISO

Source

fn chunk_index_for_offset(&self, offset: u64) -> Option<usize>

Find chunk containing a given byte offset

Source

fn chunk_start_offset(&self, chunk_index: usize) -> u64

Get the starting byte offset of a chunk

Source

pub fn read_at<F>( &self, offset: u64, buffer: &mut [u8], read_sector_fn: F, ) -> Result<usize, IsoError>
where F: FnMut(u64, u64, &mut [u8]) -> Result<usize, IsoError>,

Read data at a specific offset

The read_sector_fn callback performs the actual block I/O: fn(partition_start_lba: u64, sector_offset: u64, buffer: &mut [u8]) -> Result<usize, IsoError>

Returns number of bytes read (may be less than buffer size at EOF or chunk boundary)

Source

pub fn read_next<F>( &mut self, buffer: &mut [u8], read_sector_fn: F, ) -> Result<usize, IsoError>
where F: FnMut(u64, u64, &mut [u8]) -> Result<usize, IsoError>,

Read at current position and advance

This is the main method for sequential reading.

Source

pub fn read_range<F>( &mut self, offset: u64, buffer: &mut [u8], read_sector_fn: F, ) -> Result<usize, IsoError>
where F: FnMut(u64, u64, &mut [u8]) -> Result<usize, IsoError>,

Read a range spanning multiple chunks

This handles reading across chunk boundaries transparently.

Source

pub fn get_chunk(&self, index: usize) -> Option<&ChunkInfo>

Get chunk info by index

Source

pub fn chunks(&self) -> impl Iterator<Item = &ChunkInfo>

Iterate over all chunks

Auto Trait Implementations§

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.