morpheus_core::iso

Struct ChunkWriter

Source
pub struct ChunkWriter {
    state: WriterState,
    current_chunk: usize,
    chunk_bytes_written: u64,
    total_bytes_written: u64,
    chunk_size: u64,
    total_size: u64,
    num_chunks: usize,
    chunk_partitions: [(u64, u64); 16],
    progress_fn: Option<fn(_: u64, _: u64, _: usize, _: usize)>,
}
Expand description

Streaming chunk writer

Fields§

§state: WriterState

Current writer state

§current_chunk: usize

Current chunk index being written

§chunk_bytes_written: u64

Bytes written to current chunk

§total_bytes_written: u64

Total bytes written across all chunks

§chunk_size: u64

Target chunk size

§total_size: u64

Total expected size

§num_chunks: usize

Number of chunks

§chunk_partitions: [(u64, u64); 16]

Chunk partition info (start_lba, end_lba per chunk)

§progress_fn: Option<fn(_: u64, _: u64, _: usize, _: usize)>

Optional progress callback

Implementations§

Source§

impl ChunkWriter

Source

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

Create a new chunk writer from a manifest

The manifest must have chunk partitions already assigned

Source

pub fn new( total_size: u64, chunk_size: u64, partitions: &[(u64, u64)], ) -> Result<Self, IsoError>

Create a chunk writer with explicit parameters

Source

pub fn set_progress_fn(&mut self, f: fn(_: u64, _: u64, _: usize, _: usize))

Set progress callback

Source

pub fn state(&self) -> WriterState

Get current state

Source

pub fn bytes_written(&self) -> u64

Get total bytes written

Source

pub fn current_chunk_index(&self) -> usize

Get current chunk index

Source

pub fn progress_percent(&self) -> u8

Get progress percentage (0-100)

Source

fn chunk_for_position(&self, position: u64) -> (usize, u64)

Calculate which chunk and offset for a given byte position

Source

pub fn write<F>( &mut self, data: &[u8], write_sector_fn: F, ) -> Result<usize, IsoError>
where F: FnMut(u64, u64, &[u8]) -> Result<(), IsoError>,

Write data to chunks

This method handles splitting data across chunk boundaries. The write_sector_fn callback performs the actual block I/O: fn(partition_start_lba: u64, sector_offset: u64, data: &[u8]) -> Result<(), IsoError>

Source

pub fn finalize(&mut self) -> Result<ChunkSet, IsoError>

Finalize the writer

Call this after all data has been written. Updates chunk metadata.

Source

pub fn reset(&mut self, new_total_size: u64)

Reset writer for a new ISO (reuse allocated partitions)

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.