Skip to main content

AcquisitionWriter

Struct AcquisitionWriter 

Source
pub struct AcquisitionWriter { /* private fields */ }
Expand description

Append-only physical E01 writer with resumable sealed segments.

RAM holds a fixed number of chunk buffers and at most chunks_per_segment descriptors. Scratch disk holds at most one encoded segment, plus its copy while sealing. Completed native segments accumulate in an adjacent .ewf-acquisition directory. Self::finish publishes them without copying payloads, using hard links; the destination filesystem must support hard links and file locking.

Drop preserves sealed checkpoints. Resume discards unsealed input, verifies every sealed segment, and rehashes its decoded media to restore digest state. Supply input again starting at Self::checkpoint_offset. No sealed segment is rewritten. The source identity is a caller-supplied assertion (for example a SHA256 of stable device identifiers); this API cannot detect source changes if the caller reuses an identity. Use a stable source snapshot when needed.

Flush seals complete chunks. A partial chunk remains uncheckpointed until filled or until the declared source size is reached. Any I/O failure poisons the writer: drop it and resume to discover the last successful checkpoint. Files are synchronized before checkpoint acknowledgement; directory entries are synchronized on Unix. Windows process-crash recovery is supported, but power-loss durability is not certified.

Implementations§

Source§

impl AcquisitionWriter

Source

pub fn inspect_checkpoint( first: impl AsRef<Path>, options: &AcquisitionOptions, source_identity: [u8; 32], ) -> Result<AcquisitionCheckpoint>

Inspects checkpoint records, segment lengths, and native metadata without scanning media payloads. Requires the original configuration and identity. This does not certify segment contents; use validate_checkpoint for that.

Source

pub fn validate_checkpoint( first: impl AsRef<Path>, options: &AcquisitionOptions, source_identity: [u8; 32], on_progress: impl FnMut(AcquisitionOperationProgress) -> ControlFlow<()>, ) -> Result<AcquisitionCheckpoint>

Inspects and validates sealed container hashes with cooperative cancellation. Returning Break(()) returns EwfError::Aborted without changing checkpoint content. Media decoding/hashing is performed later by resume.

Source§

impl AcquisitionWriter

Source

pub fn acquire_from<R: Read + Seek>( &mut self, source: &mut R, options: &AcquisitionReadOptions, ) -> Result<AcquisitionOutcome>

Acquires from a seekable file or caller-opened device using the given policy. Source position is set explicitly for every attempt, including after resume.

Source

pub fn acquire_with_progress<R: Read + Seek>( &mut self, source: &mut R, options: &AcquisitionReadOptions, on_progress: impl FnMut(AcquisitionProgress) -> ControlFlow<()>, ) -> Result<AcquisitionOutcome>

Acquires with progress and cooperative cancellation. Returning Break(()) checkpoints full chunks and returns Cancelled; a partial chunk stays in this writer’s memory. Continue with this writer or drop it and resume from its checkpoint offset. Callbacks run before source I/O and between reads, retries, and writes. An in-flight OS operation or segment seal cannot be interrupted. A callback must return promptly and must not panic.

Healthy reads automatically group complete image chunks into a bounded buffer. A failed bulk attempt is discarded and retried sector by sector. Partial failed reads never enter the image. Source failures checkpoint accepted full chunks and leave the writer usable; destination failures poison it and require dropping and resuming.

Source§

impl AcquisitionWriter

Source

pub fn create( first: impl AsRef<Path>, options: &AcquisitionOptions, source_identity: [u8; 32], ) -> Result<Self>

Creates a new acquisition. Existing E01-family output is never replaced. The identity and all options must be identical when resuming.

Source

pub fn resume( first: impl AsRef<Path>, options: &AcquisitionOptions, source_identity: [u8; 32], ) -> Result<Self>

Reopens an interrupted acquisition and validates its sealed prefix. Returns an error for a different identity/configuration, corrupt or missing sealed data, or a live writer. Work is proportional to checkpointed bytes. A fully acquired but unpublished set can be resumed and finished directly.

Source

pub fn resume_with_progress( first: impl AsRef<Path>, options: &AcquisitionOptions, source_identity: [u8; 32], on_progress: impl FnMut(AcquisitionOperationProgress) -> ControlFlow<()>, ) -> Result<Self>

Resumes with cancellable segment validation and media rehash progress. Cancellation returns EwfError::Aborted and leaves checkpoint files intact.

Source

pub fn position(&self) -> u64

Number of bytes accepted in this acquisition, including unsealed bytes.

Source

pub fn checkpoint_offset(&self) -> u64

Source offset durable at the last acknowledged sealed-segment checkpoint.

Source

pub fn sealed_segments(&self) -> usize

Number of immutable native EWF segments checkpointed so far.

Source

pub fn processing_duration(&self) -> Duration

Time spent hashing and encoding new chunks in this writer instance.

Source

pub fn scratch_write_duration(&self) -> Duration

Time spent appending encoded chunks to scratch storage in this instance.

Source

pub fn segment_seal_duration(&self) -> Duration

Time spent building, synchronizing, hashing, and checkpointing segments.

Source

pub fn acquisition_errors(&self) -> &[AcquisitionError]

Unreadable source sectors replaced with zeroes, including unsealed input. Checkpointed ranges are recovered from native EWF error sections on resume.

Source

pub fn checkpoint(&mut self) -> Result<u64>

Seals complete buffered chunks and returns the resumable source offset. Any partial chunk remains in memory and is not included in this offset.

Source

pub fn finish(self) -> Result<WriteResult>

Completes and publishes the exact declared source, including MD5, SHA1, and SHA256 references. Too little input is an error, never an implicit pad. Before journal retirement, a publication error preserves checkpoints for resume(...).finish(). A cleanup failure after retirement can leave an already completed image; open the image to check that outcome.

Source

pub fn finish_with_progress( self, on_progress: impl FnMut(AcquisitionOperationProgress) -> ControlFlow<()>, ) -> Result<WriteResult>

Validates and publishes with cooperative cancellation. Returning Break leaves the acquisition resumable, including after some output links have been installed. Cancellation is checked before journal retirement; cleanup after that commit point is not cancellable.

Trait Implementations§

Source§

impl Write for AcquisitionWriter

Source§

fn write(&mut self, bytes: &[u8]) -> Result<usize>

Writes a buffer into this writer, returning how many bytes were written. Read more
Source§

fn flush(&mut self) -> Result<()>

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
1.36.0 · Source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

Like write, except that it writes from a slice of buffers. Read more
Source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
1.0.0 · Source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>

Attempts to write an entire buffer into this writer. Read more
Source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, !>

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.