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
impl AcquisitionWriter
Sourcepub fn inspect_checkpoint(
first: impl AsRef<Path>,
options: &AcquisitionOptions,
source_identity: [u8; 32],
) -> Result<AcquisitionCheckpoint>
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.
Sourcepub fn validate_checkpoint(
first: impl AsRef<Path>,
options: &AcquisitionOptions,
source_identity: [u8; 32],
on_progress: impl FnMut(AcquisitionOperationProgress) -> ControlFlow<()>,
) -> Result<AcquisitionCheckpoint>
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
impl AcquisitionWriter
Sourcepub fn acquire_from<R: Read + Seek>(
&mut self,
source: &mut R,
options: &AcquisitionReadOptions,
) -> Result<AcquisitionOutcome>
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.
Sourcepub fn acquire_with_progress<R: Read + Seek>(
&mut self,
source: &mut R,
options: &AcquisitionReadOptions,
on_progress: impl FnMut(AcquisitionProgress) -> ControlFlow<()>,
) -> Result<AcquisitionOutcome>
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
impl AcquisitionWriter
Sourcepub fn create(
first: impl AsRef<Path>,
options: &AcquisitionOptions,
source_identity: [u8; 32],
) -> Result<Self>
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.
Sourcepub fn resume(
first: impl AsRef<Path>,
options: &AcquisitionOptions,
source_identity: [u8; 32],
) -> Result<Self>
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.
Sourcepub fn resume_with_progress(
first: impl AsRef<Path>,
options: &AcquisitionOptions,
source_identity: [u8; 32],
on_progress: impl FnMut(AcquisitionOperationProgress) -> ControlFlow<()>,
) -> Result<Self>
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.
Sourcepub fn position(&self) -> u64
pub fn position(&self) -> u64
Number of bytes accepted in this acquisition, including unsealed bytes.
Sourcepub fn checkpoint_offset(&self) -> u64
pub fn checkpoint_offset(&self) -> u64
Source offset durable at the last acknowledged sealed-segment checkpoint.
Sourcepub fn sealed_segments(&self) -> usize
pub fn sealed_segments(&self) -> usize
Number of immutable native EWF segments checkpointed so far.
Sourcepub fn processing_duration(&self) -> Duration
pub fn processing_duration(&self) -> Duration
Time spent hashing and encoding new chunks in this writer instance.
Sourcepub fn scratch_write_duration(&self) -> Duration
pub fn scratch_write_duration(&self) -> Duration
Time spent appending encoded chunks to scratch storage in this instance.
Sourcepub fn segment_seal_duration(&self) -> Duration
pub fn segment_seal_duration(&self) -> Duration
Time spent building, synchronizing, hashing, and checkpointing segments.
Sourcepub fn acquisition_errors(&self) -> &[AcquisitionError]
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.
Sourcepub fn checkpoint(&mut self) -> Result<u64>
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.
Sourcepub fn finish(self) -> Result<WriteResult>
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.
Sourcepub fn finish_with_progress(
self,
on_progress: impl FnMut(AcquisitionOperationProgress) -> ControlFlow<()>,
) -> Result<WriteResult>
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
impl Write for AcquisitionWriter
Source§fn write(&mut self, bytes: &[u8]) -> Result<usize>
fn write(&mut self, bytes: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)Auto Trait Implementations§
impl Freeze for AcquisitionWriter
impl RefUnwindSafe for AcquisitionWriter
impl Send for AcquisitionWriter
impl Sync for AcquisitionWriter
impl Unpin for AcquisitionWriter
impl UnsafeUnpin for AcquisitionWriter
impl UnwindSafe for AcquisitionWriter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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