pub struct EwfWriter { /* private fields */ }Expand description
Incremental EWF writer.
The writer buffers media data until EwfWriter::finish or another finish
method is called. Geometry and format options must be configured before
media data is written.
Implementations§
Source§impl EwfWriter
impl EwfWriter
Sourcepub fn create(path: impl AsRef<Path>, options: WriteOptions) -> Result<Self>
pub fn create(path: impl AsRef<Path>, options: WriteOptions) -> Result<Self>
Creates a new writer for a file-backed EWF segment set.
§Errors
Returns an error if options are invalid, the secondary segment filename conflicts with the primary filename, or temporary spool creation fails.
Sourcepub fn create_from_image(path: impl AsRef<Path>, image: &Image) -> Result<Self>
pub fn create_from_image(path: impl AsRef<Path>, image: &Image) -> Result<Self>
Creates a writer initialized from an existing image and copies its media.
§Errors
Returns an error if the source image cannot be represented by the writer, media copying fails, or writer creation fails.
Sourcepub fn resume<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn resume<P: AsRef<Path>>(path: P) -> Result<Self>
Opens an existing image and prepares a writer that can append or rewrite it.
§Errors
Returns an error if the existing image cannot be opened, copied, or represented by writer options.
Sourcepub fn segment_filename(&self) -> &Path
pub fn segment_filename(&self) -> &Path
Returns the first output segment filename.
Sourcepub fn set_segment_filename(&mut self, path: impl AsRef<Path>)
pub fn set_segment_filename(&mut self, path: impl AsRef<Path>)
Sets the first output segment filename.
Sourcepub fn secondary_segment_filename(&self) -> Option<&Path>
pub fn secondary_segment_filename(&self) -> Option<&Path>
Returns the first mirrored secondary output segment filename.
Sourcepub fn set_secondary_segment_filename(
&mut self,
path: impl AsRef<Path>,
) -> Result<()>
pub fn set_secondary_segment_filename( &mut self, path: impl AsRef<Path>, ) -> Result<()>
Sets the first mirrored secondary output segment filename.
§Errors
Returns an error if the secondary filename conflicts with the primary output filename.
Sourcepub fn clear_secondary_segment_filename(&mut self)
pub fn clear_secondary_segment_filename(&mut self)
Clears mirrored secondary output.
Sourcepub fn write_all(&mut self, data: &[u8]) -> Result<()>
pub fn write_all(&mut self, data: &[u8]) -> Result<()>
Writes all bytes at the current writer position.
§Errors
Returns an error if the writer has been aborted or writing would exceed configured limits.
Sourcepub fn write_buffer(&mut self, data: &[u8]) -> Result<usize>
pub fn write_buffer(&mut self, data: &[u8]) -> Result<usize>
Writes bytes at the current writer position and returns the byte count.
§Errors
Returns an error if the writer has been aborted or writing would exceed configured limits.
Sourcepub fn write_at(&mut self, data: &[u8], offset: u64) -> Result<usize>
pub fn write_at(&mut self, data: &[u8], offset: u64) -> Result<usize>
Writes bytes at an absolute logical byte offset.
§Errors
Returns an error if the writer has been aborted or writing would exceed configured limits.
Sourcepub fn write_data_chunk(&mut self, chunk: &DataChunk) -> Result<usize>
pub fn write_data_chunk(&mut self, chunk: &DataChunk) -> Result<usize>
Writes a decoded data chunk at the current writer position.
§Errors
Returns an error if the chunk metadata is inconsistent, the writer has been aborted, or writing would exceed configured limits.
Sourcepub fn write_encoded_data_chunk(
&mut self,
chunk: &EncodedDataChunk,
) -> Result<usize>
pub fn write_encoded_data_chunk( &mut self, chunk: &EncodedDataChunk, ) -> Result<usize>
Decodes and writes an encoded data chunk at the current writer position.
§Errors
Returns an error if the encoded chunk cannot be decoded, the writer has been aborted, or writing would exceed configured limits.
Sourcepub fn write_data_chunk_at(
&mut self,
chunk: &DataChunk,
offset: u64,
) -> Result<usize>
pub fn write_data_chunk_at( &mut self, chunk: &DataChunk, offset: u64, ) -> Result<usize>
Writes a decoded data chunk at an absolute logical byte offset.
§Errors
Returns the same errors as EwfWriter::write_data_chunk and
EwfWriter::write_at.
Sourcepub fn write_encoded_data_chunk_at(
&mut self,
chunk: &EncodedDataChunk,
offset: u64,
) -> Result<usize>
pub fn write_encoded_data_chunk_at( &mut self, chunk: &EncodedDataChunk, offset: u64, ) -> Result<usize>
Decodes and writes an encoded data chunk at an absolute logical byte offset.
§Errors
Returns the same errors as EwfWriter::write_encoded_data_chunk and
EwfWriter::write_at.
Sourcepub fn format(&self) -> WriteFormat
pub fn format(&self) -> WriteFormat
Returns the configured output format.
Sourcepub fn set_format(&mut self, format: WriteFormat) -> Result<()>
pub fn set_format(&mut self, format: WriteFormat) -> Result<()>
Sets the output format before media data is written.
§Errors
Returns an error if media data has already been written or the new option combination is unsupported.
Sourcepub fn chunk_size(&self) -> u64
pub fn chunk_size(&self) -> u64
Returns the current logical chunk size in bytes.
Sourcepub fn sectors_per_chunk(&self) -> u32
pub fn sectors_per_chunk(&self) -> u32
Returns the configured sectors per chunk.
Sourcepub fn set_sectors_per_chunk(&mut self, sectors_per_chunk: u32) -> Result<()>
pub fn set_sectors_per_chunk(&mut self, sectors_per_chunk: u32) -> Result<()>
Sets sectors per chunk before media data is written.
§Errors
Returns an error if media data has already been written or the resulting chunk geometry is invalid.
Sourcepub fn bytes_per_sector(&self) -> u32
pub fn bytes_per_sector(&self) -> u32
Returns the configured bytes per sector.
Sourcepub fn set_bytes_per_sector(&mut self, bytes_per_sector: u32) -> Result<()>
pub fn set_bytes_per_sector(&mut self, bytes_per_sector: u32) -> Result<()>
Sets bytes per sector before media data is written.
§Errors
Returns an error if media data has already been written or the resulting chunk geometry is invalid.
Sourcepub fn logical_size(&self) -> Result<u64>
pub fn logical_size(&self) -> Result<u64>
Returns the logical size that would be written after sector padding.
§Errors
Returns an error if configured sizes overflow or are inconsistent.
Sourcepub fn media_size(&self) -> Result<u64>
pub fn media_size(&self) -> Result<u64>
Sourcepub fn number_of_sectors(&self) -> Result<u64>
pub fn number_of_sectors(&self) -> Result<u64>
Returns the logical sector count that would be written.
§Errors
Returns an error if the logical size cannot be computed.
Sourcepub fn maximum_segment_size(&self) -> Option<u64>
pub fn maximum_segment_size(&self) -> Option<u64>
Returns the configured maximum segment size in bytes.
Sourcepub fn set_maximum_segment_size(
&mut self,
maximum_segment_size: Option<u64>,
) -> Result<()>
pub fn set_maximum_segment_size( &mut self, maximum_segment_size: Option<u64>, ) -> Result<()>
Sets the maximum segment size before media data is written.
§Errors
Returns an error if media data has already been written or the value is invalid for the current output format.
Sourcepub fn set_media_size(&mut self, media_size: u64) -> Result<()>
pub fn set_media_size(&mut self, media_size: u64) -> Result<()>
Sets the declared logical media size before media data is written.
§Errors
Returns an error if media data has already been written or the requested size is smaller than data already written.
Sourcepub fn number_of_chunks_written(&self) -> Result<u64>
pub fn number_of_chunks_written(&self) -> Result<u64>
Returns the number of logical chunks that would be written.
§Errors
Returns an error if the logical size cannot be computed.
Sourcepub fn segment_file_set_identifier(&self) -> Option<[u8; 16]>
pub fn segment_file_set_identifier(&self) -> Option<[u8; 16]>
Returns the configured segment set identifier.
Sourcepub fn signal_abort(&self)
pub fn signal_abort(&self)
Signals future writer operations to abort with EwfError::Aborted.
Sourcepub fn set_segment_file_set_identifier(
&mut self,
set_identifier: [u8; 16],
) -> Result<()>
pub fn set_segment_file_set_identifier( &mut self, set_identifier: [u8; 16], ) -> Result<()>
Sets the segment set identifier before media data is written.
§Errors
Returns an error if media data has already been written.
Sourcepub fn compression_method(&self) -> WriteCompression
pub fn compression_method(&self) -> WriteCompression
Returns the configured compression method.
Sourcepub fn set_compression_method(
&mut self,
compression: WriteCompression,
) -> Result<()>
pub fn set_compression_method( &mut self, compression: WriteCompression, ) -> Result<()>
Sets the compression method before media data is written.
§Errors
Returns an error if media data has already been written or BZip2 is
selected for an EWF1 output format.
Sourcepub fn compression_values(&self) -> WriteCompressionValues
pub fn compression_values(&self) -> WriteCompressionValues
Returns the configured compression values.
Sourcepub fn set_compression_values(
&mut self,
compression_values: WriteCompressionValues,
) -> Result<()>
pub fn set_compression_values( &mut self, compression_values: WriteCompressionValues, ) -> Result<()>
Sets compression values before media data is written.
§Errors
Returns an error if media data has already been written.
Sourcepub fn media_type(&self) -> Option<MediaType>
pub fn media_type(&self) -> Option<MediaType>
Returns the configured media type.
Sourcepub fn set_media_type(&mut self, media_type: Option<MediaType>) -> Result<()>
pub fn set_media_type(&mut self, media_type: Option<MediaType>) -> Result<()>
Sets the media type before media data is written.
§Errors
Returns an error if media data has already been written.
Sourcepub fn error_granularity(&self) -> Option<u64>
pub fn error_granularity(&self) -> Option<u64>
Returns the configured error granularity in sectors.
Sourcepub fn set_error_granularity(
&mut self,
error_granularity: Option<u64>,
) -> Result<()>
pub fn set_error_granularity( &mut self, error_granularity: Option<u64>, ) -> Result<()>
Sets error granularity before media data is written.
§Errors
Returns an error if media data has already been written.
Sourcepub fn media_flags(&self) -> MediaFlags
pub fn media_flags(&self) -> MediaFlags
Returns media flags derived from format and media profile options.
Sourcepub fn set_media_flags(&mut self, media_flags: MediaFlags) -> Result<()>
pub fn set_media_flags(&mut self, media_flags: MediaFlags) -> Result<()>
Sets writable media flags before media data is written.
The physical flag is controlled by WriteFormat and cannot be changed
independently.
§Errors
Returns an error if media data has already been written or if the physical flag conflicts with the output format.
Sourcepub fn copy_media_values_from_image(&mut self, image: &Image) -> Result<()>
pub fn copy_media_values_from_image(&mut self, image: &Image) -> Result<()>
Copies media geometry and flags from an opened image.
§Errors
Returns an error if the source values cannot be represented or conflict with media data already written.
Sourcepub fn copy_media_values_from_info(&mut self, info: &ImageInfo) -> Result<()>
pub fn copy_media_values_from_info(&mut self, info: &ImageInfo) -> Result<()>
Copies media geometry and flags from parsed image metadata.
§Errors
Returns an error if the source values cannot be represented or conflict with media data already written.
Sourcepub fn header_value(&self, identifier: &str) -> Option<Cow<'_, str>>
pub fn header_value(&self, identifier: &str) -> Option<Cow<'_, str>>
Returns a configured header value by EWF identifier.
Sourcepub fn header_codepage(&self) -> HeaderCodepage
pub fn header_codepage(&self) -> HeaderCodepage
Returns the configured header codepage.
Sourcepub fn set_header_codepage(&mut self, header_codepage: HeaderCodepage)
pub fn set_header_codepage(&mut self, header_codepage: HeaderCodepage)
Sets the header codepage.
Sourcepub fn header_values_date_format(&self) -> HeaderDateFormat
pub fn header_values_date_format(&self) -> HeaderDateFormat
Returns the configured header date format.
Sourcepub fn set_header_values_date_format(&mut self, date_format: HeaderDateFormat)
pub fn set_header_values_date_format(&mut self, date_format: HeaderDateFormat)
Sets the header date format.
Sourcepub fn copy_header_values_from_image(&mut self, image: &Image)
pub fn copy_header_values_from_image(&mut self, image: &Image)
Copies header values from an opened image.
Sourcepub fn copy_header_values_from_info(&mut self, info: &ImageInfo)
pub fn copy_header_values_from_info(&mut self, info: &ImageInfo)
Copies header values from parsed image metadata.
Sourcepub fn copy_header_values_from_metadata(&mut self, metadata: &EwfMetadata)
pub fn copy_header_values_from_metadata(&mut self, metadata: &EwfMetadata)
Copies header values from metadata.
Sourcepub fn copy_hash_values_from_image(&mut self, image: &Image)
pub fn copy_hash_values_from_image(&mut self, image: &Image)
Copies stored hash values from an opened image.
Sourcepub fn copy_hash_values_from_info(&mut self, info: &ImageInfo)
pub fn copy_hash_values_from_info(&mut self, info: &ImageInfo)
Copies stored hash values from parsed image metadata.
Sourcepub fn copy_hash_values_from_stored_hashes(&mut self, hashes: &StoredHashes)
pub fn copy_hash_values_from_stored_hashes(&mut self, hashes: &StoredHashes)
Copies stored hash values from a hash collection.
Sourcepub fn set_header_value(
&mut self,
identifier: &str,
value: impl Into<String>,
) -> Option<String>
pub fn set_header_value( &mut self, identifier: &str, value: impl Into<String>, ) -> Option<String>
Sets a header value by EWF identifier and returns the previous value.
Sourcepub fn number_of_header_values(&self) -> usize
pub fn number_of_header_values(&self) -> usize
Returns the number of configured header values.
Sourcepub fn header_value_identifier(&self, index: usize) -> Option<&str>
pub fn header_value_identifier(&self, index: usize) -> Option<&str>
Returns a configured header value identifier by enumeration index.
Sourcepub fn hash_value(&self, identifier: &str) -> Option<&str>
pub fn hash_value(&self, identifier: &str) -> Option<&str>
Returns a configured hash string by identifier.
Sourcepub fn set_hash_value(
&mut self,
identifier: impl Into<String>,
value: impl Into<String>,
) -> Result<Option<String>>
pub fn set_hash_value( &mut self, identifier: impl Into<String>, value: impl Into<String>, ) -> Result<Option<String>>
Sets a configured hash string by identifier and returns the previous value.
§Errors
Returns an error if an MD5 or SHA1 value is not valid hexadecimal of
the required length.
Sourcepub fn number_of_hash_values(&self) -> usize
pub fn number_of_hash_values(&self) -> usize
Returns the number of configured hash strings.
Sourcepub fn hash_value_identifier(&self, index: usize) -> Option<&str>
pub fn hash_value_identifier(&self, index: usize) -> Option<&str>
Returns a configured hash identifier by enumeration index.
Sourcepub fn acquisition_errors(&self) -> &[AcquisitionError]
pub fn acquisition_errors(&self) -> &[AcquisitionError]
Returns configured acquisition error ranges.
Sourcepub fn number_of_acquisition_errors(&self) -> usize
pub fn number_of_acquisition_errors(&self) -> usize
Returns the number of configured acquisition error ranges.
Sourcepub fn acquisition_error(&self, index: usize) -> Option<&AcquisitionError>
pub fn acquisition_error(&self, index: usize) -> Option<&AcquisitionError>
Returns a configured acquisition error range by index.
Sourcepub fn append_acquisition_error(
&mut self,
first_sector: u64,
sector_count: u64,
) -> Result<()>
pub fn append_acquisition_error( &mut self, first_sector: u64, sector_count: u64, ) -> Result<()>
Appends an acquisition error range.
§Errors
This method currently validates no additional constraints and returns
Ok(()) after appending.
Sourcepub fn checksum_errors(&self) -> &[SectorRange]
pub fn checksum_errors(&self) -> &[SectorRange]
Returns configured checksum error ranges.
Sourcepub fn number_of_checksum_errors(&self) -> usize
pub fn number_of_checksum_errors(&self) -> usize
Returns the number of configured checksum error ranges.
Sourcepub fn checksum_error(&self, index: usize) -> Option<&SectorRange>
pub fn checksum_error(&self, index: usize) -> Option<&SectorRange>
Returns a configured checksum error range by index.
Sourcepub fn append_checksum_error(
&mut self,
first_sector: u64,
sector_count: u64,
) -> Result<()>
pub fn append_checksum_error( &mut self, first_sector: u64, sector_count: u64, ) -> Result<()>
Appends a checksum error range.
§Errors
This method currently validates no additional constraints and returns
Ok(()) after appending.
Sourcepub fn sessions(&self) -> &[SectorRange]
pub fn sessions(&self) -> &[SectorRange]
Returns configured session sector ranges.
Sourcepub fn number_of_sessions(&self) -> usize
pub fn number_of_sessions(&self) -> usize
Returns the number of configured session sector ranges.
Sourcepub fn session(&self, index: usize) -> Option<&SectorRange>
pub fn session(&self, index: usize) -> Option<&SectorRange>
Returns a configured session sector range by index.
Sourcepub fn append_session(
&mut self,
first_sector: u64,
sector_count: u64,
) -> Result<()>
pub fn append_session( &mut self, first_sector: u64, sector_count: u64, ) -> Result<()>
Appends a session sector range.
§Errors
Returns an error if the range values exceed the signed 64-bit range required by EWF metadata.
Sourcepub fn tracks(&self) -> &[SectorRange]
pub fn tracks(&self) -> &[SectorRange]
Returns configured track sector ranges.
Sourcepub fn number_of_tracks(&self) -> usize
pub fn number_of_tracks(&self) -> usize
Returns the number of configured track sector ranges.
Sourcepub fn track(&self, index: usize) -> Option<&SectorRange>
pub fn track(&self, index: usize) -> Option<&SectorRange>
Returns a configured track sector range by index.
Sourcepub fn append_track(
&mut self,
first_sector: u64,
sector_count: u64,
) -> Result<()>
pub fn append_track( &mut self, first_sector: u64, sector_count: u64, ) -> Result<()>
Appends a track sector range.
§Errors
Returns an error if the range values exceed the signed 64-bit range required by EWF metadata.
Sourcepub fn seek_offset(&mut self, position: SeekFrom) -> Result<u64>
pub fn seek_offset(&mut self, position: SeekFrom) -> Result<u64>
Seeks the writer position and returns the new position.
§Errors
Returns an error if the seek would move before the start of the media or beyond representable bounds.
Sourcepub fn seek_position(&mut self, position: SeekFrom) -> Result<u64>
pub fn seek_position(&mut self, position: SeekFrom) -> Result<u64>
Seeks the writer position and returns the new position.
§Errors
Returns an error if the seek would move before the start of the media or beyond representable bounds.
Sourcepub fn finish(self) -> Result<WriteResult>
pub fn finish(self) -> Result<WriteResult>
Finalizes a complete image and writes a terminal done marker.
§Errors
Returns an error if output cannot be prepared, encoded, written, flushed, or mirrored.
Sourcepub fn finish_incomplete(self) -> Result<WriteResult>
pub fn finish_incomplete(self) -> Result<WriteResult>
Finalizes an incomplete image with a continuation marker.
§Errors
Returns an error if output cannot be prepared, encoded, written, flushed, or mirrored.
Sourcepub fn write_finalize(self) -> Result<WriteResult>
pub fn write_finalize(self) -> Result<WriteResult>
Sourcepub fn finish_to_writer<W: Write>(self, writer: &mut W) -> Result<WriteResult>
pub fn finish_to_writer<W: Write>(self, writer: &mut W) -> Result<WriteResult>
Finalizes the image to one supplied writer.
§Errors
Returns an error if the image requires multiple output segments, if secondary output is configured, or if output preparation/writing fails.
Sourcepub fn finish_to_segment_writers<P, W, I>(
self,
segment_writers: I,
) -> Result<WriteResult>
pub fn finish_to_segment_writers<P, W, I>( self, segment_writers: I, ) -> Result<WriteResult>
Finalizes the image to explicitly supplied segment writers.
The number of supplied writers must match the number of output segments implied by the current writer configuration.
§Errors
Returns an error if secondary output is configured, if the writer count does not match the computed segment count, or if output preparation/writing fails.
Trait Implementations§
Source§impl Seek for EwfWriter
impl Seek for EwfWriter
Source§fn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
Source§fn stream_position(&mut self) -> Result<u64>
fn stream_position(&mut self) -> Result<u64>
1.55.0 · Source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Source§impl Write for EwfWriter
impl Write for EwfWriter
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[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)