Skip to main content

EwfWriter

Struct EwfWriter 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn filename(&self) -> &Path

Returns the first output segment filename.

Source

pub fn segment_filename(&self) -> &Path

Returns the first output segment filename.

Source

pub fn set_segment_filename(&mut self, path: impl AsRef<Path>)

Sets the first output segment filename.

Source

pub fn secondary_segment_filename(&self) -> Option<&Path>

Returns the first mirrored secondary output segment filename.

Source

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.

Source

pub fn clear_secondary_segment_filename(&mut self)

Clears mirrored secondary output.

Source

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.

Source

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.

Source

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.

Source

pub fn write_buffer_at_offset( &mut self, data: &[u8], offset: u64, ) -> Result<usize>

Alias for EwfWriter::write_at.

§Errors

Returns the same errors as EwfWriter::write_at.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn format(&self) -> WriteFormat

Returns the configured output format.

Source

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.

Source

pub fn position(&self) -> u64

Returns the current logical byte write position.

Source

pub fn chunk_size(&self) -> u64

Returns the current logical chunk size in bytes.

Source

pub fn sectors_per_chunk(&self) -> u32

Returns the configured sectors per chunk.

Source

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.

Source

pub fn bytes_per_sector(&self) -> u32

Returns the configured bytes per sector.

Source

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.

Source

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.

Source

pub fn media_size(&self) -> Result<u64>

Alias for EwfWriter::logical_size.

§Errors

Returns the same errors as EwfWriter::logical_size.

Source

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.

Source

pub fn maximum_segment_size(&self) -> Option<u64>

Returns the configured maximum segment size in bytes.

Source

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.

Source

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.

Source

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.

Source

pub fn segment_file_set_identifier(&self) -> Option<[u8; 16]>

Returns the configured segment set identifier.

Source

pub fn signal_abort(&self)

Signals future writer operations to abort with EwfError::Aborted.

Source

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.

Source

pub fn compression_method(&self) -> WriteCompression

Returns the configured compression method.

Source

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.

Source

pub fn compression_values(&self) -> WriteCompressionValues

Returns the configured compression values.

Source

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.

Source

pub fn media_type(&self) -> Option<MediaType>

Returns the configured media type.

Source

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.

Source

pub fn error_granularity(&self) -> Option<u64>

Returns the configured error granularity in sectors.

Source

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.

Source

pub fn media_flags(&self) -> MediaFlags

Returns media flags derived from format and media profile options.

Source

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.

Source

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.

Source

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.

Source

pub fn header_value(&self, identifier: &str) -> Option<Cow<'_, str>>

Returns a configured header value by EWF identifier.

Source

pub fn header_codepage(&self) -> HeaderCodepage

Returns the configured header codepage.

Source

pub fn set_header_codepage(&mut self, header_codepage: HeaderCodepage)

Sets the header codepage.

Source

pub fn header_values_date_format(&self) -> HeaderDateFormat

Returns the configured header date format.

Source

pub fn set_header_values_date_format(&mut self, date_format: HeaderDateFormat)

Sets the header date format.

Source

pub fn copy_header_values_from_image(&mut self, image: &Image)

Copies header values from an opened image.

Source

pub fn copy_header_values_from_info(&mut self, info: &ImageInfo)

Copies header values from parsed image metadata.

Source

pub fn copy_header_values_from_metadata(&mut self, metadata: &EwfMetadata)

Copies header values from metadata.

Source

pub fn copy_hash_values_from_image(&mut self, image: &Image)

Copies stored hash values from an opened image.

Source

pub fn copy_hash_values_from_info(&mut self, info: &ImageInfo)

Copies stored hash values from parsed image metadata.

Source

pub fn copy_hash_values_from_stored_hashes(&mut self, hashes: &StoredHashes)

Copies stored hash values from a hash collection.

Source

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.

Source

pub fn number_of_header_values(&self) -> usize

Returns the number of configured header values.

Source

pub fn header_value_identifier(&self, index: usize) -> Option<&str>

Returns a configured header value identifier by enumeration index.

Source

pub fn hash_value(&self, identifier: &str) -> Option<&str>

Returns a configured hash string by identifier.

Source

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.

Source

pub fn number_of_hash_values(&self) -> usize

Returns the number of configured hash strings.

Source

pub fn hash_value_identifier(&self, index: usize) -> Option<&str>

Returns a configured hash identifier by enumeration index.

Source

pub fn md5_hash(&self) -> Option<[u8; 16]>

Returns the configured MD5 hash bytes.

Source

pub fn set_md5_hash(&mut self, md5: [u8; 16]) -> Result<()>

Sets the configured MD5 hash bytes.

§Errors

Returns an error if an MD5 hash is already configured.

Source

pub fn sha1_hash(&self) -> Option<[u8; 20]>

Returns the configured SHA1 hash bytes.

Source

pub fn set_sha1_hash(&mut self, sha1: [u8; 20]) -> Result<()>

Sets the configured SHA1 hash bytes.

§Errors

Returns an error if a SHA1 hash is already configured.

Source

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

Returns configured acquisition error ranges.

Source

pub fn number_of_acquisition_errors(&self) -> usize

Returns the number of configured acquisition error ranges.

Source

pub fn acquisition_error(&self, index: usize) -> Option<&AcquisitionError>

Returns a configured acquisition error range by index.

Source

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.

Source

pub fn checksum_errors(&self) -> &[SectorRange]

Returns configured checksum error ranges.

Source

pub fn number_of_checksum_errors(&self) -> usize

Returns the number of configured checksum error ranges.

Source

pub fn checksum_error(&self, index: usize) -> Option<&SectorRange>

Returns a configured checksum error range by index.

Source

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.

Source

pub fn sessions(&self) -> &[SectorRange]

Returns configured session sector ranges.

Source

pub fn number_of_sessions(&self) -> usize

Returns the number of configured session sector ranges.

Source

pub fn session(&self, index: usize) -> Option<&SectorRange>

Returns a configured session sector range by index.

Source

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.

Source

pub fn tracks(&self) -> &[SectorRange]

Returns configured track sector ranges.

Source

pub fn number_of_tracks(&self) -> usize

Returns the number of configured track sector ranges.

Source

pub fn track(&self, index: usize) -> Option<&SectorRange>

Returns a configured track sector range by index.

Source

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.

Source

pub fn offset(&self) -> u64

Returns the current logical byte write position.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Alias for EwfWriter::finish.

§Errors

Returns the same errors as EwfWriter::finish.

Source

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.

Source

pub fn finish_to_segment_writers<P, W, I>( self, segment_writers: I, ) -> Result<WriteResult>
where P: Into<PathBuf>, W: Write, I: IntoIterator<Item = (P, W)>,

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 Debug for EwfWriter

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Seek for EwfWriter

Source§

fn seek(&mut self, pos: SeekFrom) -> Result<u64>

Seek to an offset, in bytes, in a stream. Read more
Source§

fn stream_position(&mut self) -> Result<u64>

Returns the current seek position from the start of the stream. Read more
1.55.0 · Source§

fn rewind(&mut self) -> Result<(), Error>

Rewind to the beginning of a stream. Read more
Source§

fn stream_len(&mut self) -> Result<u64, Error>

🔬This is a nightly-only experimental API. (seek_stream_len)
Returns the length of this stream (in bytes). Read more
1.80.0 · Source§

fn seek_relative(&mut self, offset: i64) -> Result<(), Error>

Seeks relative to the current position. Read more
Source§

impl Write for EwfWriter

Source§

fn write(&mut self, buf: &[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> 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 = 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.