pub struct Image { /* private fields */ }Expand description
Opened EWF image and logical media reader.
Implementations§
Source§impl Image
impl Image
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self>
pub fn open(path: impl AsRef<Path>) -> Result<Self>
Opens an EWF image from the first segment path.
Adjacent segments are discovered automatically from the first path.
§Errors
Returns an error if no segment set can be discovered, a segment cannot be read, or the image is unsupported or malformed.
Sourcepub fn open_with_options(
path: impl AsRef<Path>,
options: OpenOptions,
) -> Result<Self>
pub fn open_with_options( path: impl AsRef<Path>, options: OpenOptions, ) -> Result<Self>
Opens an EWF image from the first segment path with explicit options.
§Errors
Returns an error if no segment set can be discovered, a segment cannot be read, or the image is unsupported or malformed.
Sourcepub fn open_segments<P, I>(paths: I) -> Result<Self>
pub fn open_segments<P, I>(paths: I) -> Result<Self>
Opens an EWF image from an explicit ordered segment path list.
§Errors
Returns an error if the list is empty, a segment cannot be read, or the image is unsupported or malformed.
Sourcepub fn open_segments_with_options<P, I>(
paths: I,
options: OpenOptions,
) -> Result<Self>
pub fn open_segments_with_options<P, I>( paths: I, options: OpenOptions, ) -> Result<Self>
Opens an EWF image from explicit ordered segment paths with options.
§Errors
Returns an error if the list is empty, a segment cannot be read, or the image is unsupported or malformed.
Sourcepub fn open_readers<N, R, I>(segments: I) -> Result<Self>
pub fn open_readers<N, R, I>(segments: I) -> Result<Self>
Opens an EWF image from supplied readers and segment labels.
Supplied readers are kept by the image and are not reopened from the filesystem. Labels are used anywhere this crate reports segment paths.
§Errors
Returns an error if the list is empty, a reader fails, or the image is unsupported or malformed.
Sourcepub fn open_readers_with_options<N, R, I>(
segments: I,
options: OpenOptions,
) -> Result<Self>
pub fn open_readers_with_options<N, R, I>( segments: I, options: OpenOptions, ) -> Result<Self>
Opens an EWF image from supplied readers with explicit options.
§Errors
Returns an error if the list is empty, a reader fails, or the image is unsupported or malformed.
Sourcepub fn reader_statistics(&self) -> Option<ReaderStatistics>
pub fn reader_statistics(&self) -> Option<ReaderStatistics>
Returns cumulative reader counters when statistics were enabled at open time.
Snapshots are shared across clones and cursors created from this image.
Sourcepub fn reader_cache_info(&self) -> ReaderCacheInfo
pub fn reader_cache_info(&self) -> ReaderCacheInfo
Returns configured capacities and retained table-page payload bytes.
Sourcepub fn number_of_segments(&self) -> usize
pub fn number_of_segments(&self) -> usize
Returns the number of segments in the opened image.
Sourcepub fn maximum_number_of_open_handles(&self) -> Result<Option<usize>>
pub fn maximum_number_of_open_handles(&self) -> Result<Option<usize>>
Returns the configured maximum number of open segment handles.
§Errors
Returns an error if the internal segment pool lock is poisoned.
Sourcepub fn set_maximum_number_of_open_handles(
&self,
maximum_open_handles: Option<usize>,
) -> Result<()>
pub fn set_maximum_number_of_open_handles( &self, maximum_open_handles: Option<usize>, ) -> Result<()>
Updates the maximum number of open segment handles.
None allows all handles to remain open. Supplied-reader images cannot
evict and reopen readers, so this value is validated against the reader
set.
§Errors
Returns an error if the value is invalid for supplied readers or if the internal segment pool lock is poisoned.
Sourcepub fn number_of_open_segment_handles(&self) -> Result<usize>
pub fn number_of_open_segment_handles(&self) -> Result<usize>
Returns the current number of open segment handles.
§Errors
Returns an error if the internal segment pool lock is poisoned.
Sourcepub fn segment_filenames(&self) -> &[PathBuf]
pub fn segment_filenames(&self) -> &[PathBuf]
Returns all segment filenames or supplied-reader labels.
Sourcepub fn segment_filename(&self, index: usize) -> Option<&Path>
pub fn segment_filename(&self, index: usize) -> Option<&Path>
Returns one segment filename or supplied-reader label by index.
Sourcepub fn segment_set_size(&self) -> Result<u64>
pub fn segment_set_size(&self) -> Result<u64>
Returns the total byte size of all opened segment containers.
For supplied readers, this uses SegmentReader::segment_len.
§Errors
Returns an error if a segment length cannot be read, the internal segment
pool lock is poisoned, or the total size overflows u64.
Sourcepub fn segment_files_corrupted(&self) -> Result<bool>
pub fn segment_files_corrupted(&self) -> Result<bool>
Probes path-backed segment files for corruption-style structural errors.
Images opened from supplied readers return false because there are no
filesystem paths to reprobe.
§Errors
Returns an error if a path-backed probe fails unexpectedly.
Sourcepub fn segment_files_encrypted(&self) -> Result<bool>
pub fn segment_files_encrypted(&self) -> Result<bool>
Probes path-backed segment files for EWF2 encryption markers.
Images opened from supplied readers return false because there are no
filesystem paths to reprobe.
§Errors
Returns an error if a path-backed probe fails unexpectedly.
Sourcepub fn segment_filename_for_chunk(&self, chunk_index: u64) -> Result<&Path>
pub fn segment_filename_for_chunk(&self, chunk_index: u64) -> Result<&Path>
Returns the segment containing a logical chunk.
§Errors
Returns an error if chunk_index is outside the parsed chunk index or if
the chunk index references a missing segment.
Sourcepub fn segment_filename_for_offset(&self, offset: u64) -> Result<Option<&Path>>
pub fn segment_filename_for_offset(&self, offset: u64) -> Result<Option<&Path>>
Returns the segment containing a logical byte offset.
Offsets at or beyond the logical media size return Ok(None).
§Errors
Returns an error if the chunk geometry is malformed.
Sourcepub fn format_profile(&self) -> FormatProfile
pub fn format_profile(&self) -> FormatProfile
Returns the inferred format profile.
Sourcepub fn chunk_size(&self) -> u64
pub fn chunk_size(&self) -> u64
Returns the logical chunk size in bytes.
Sourcepub fn media_size(&self) -> u64
pub fn media_size(&self) -> u64
Returns the logical media size in bytes.
Sourcepub fn header_codepage(&self) -> HeaderCodepage
pub fn header_codepage(&self) -> HeaderCodepage
Returns the header codepage used for decoded EWF1 values.
Sourcepub fn header_values_date_format(&self) -> HeaderDateFormat
pub fn header_values_date_format(&self) -> HeaderDateFormat
Returns the date format applied to header date values.
Sourcepub fn sectors_per_chunk(&self) -> Option<u64>
pub fn sectors_per_chunk(&self) -> Option<u64>
Returns sectors per chunk from media metadata.
Sourcepub fn bytes_per_sector(&self) -> Option<u64>
pub fn bytes_per_sector(&self) -> Option<u64>
Returns bytes per sector from media metadata.
Sourcepub fn number_of_sectors(&self) -> Option<u64>
pub fn number_of_sectors(&self) -> Option<u64>
Returns the logical sector count from media metadata.
Sourcepub fn number_of_chunks(&self) -> Option<u64>
pub fn number_of_chunks(&self) -> Option<u64>
Returns the logical chunk count from media metadata.
Sourcepub fn error_granularity(&self) -> Option<u64>
pub fn error_granularity(&self) -> Option<u64>
Returns error granularity in sectors from media metadata.
Sourcepub fn segment_file_set_identifier(&self) -> Option<[u8; 16]>
pub fn segment_file_set_identifier(&self) -> Option<[u8; 16]>
Returns the segment set identifier.
Sourcepub fn segment_file_version(&self) -> Option<SegmentFileVersion>
pub fn segment_file_version(&self) -> Option<SegmentFileVersion>
Returns the EWF2 segment file version.
Sourcepub fn compression_method(&self) -> Option<CompressionMethod>
pub fn compression_method(&self) -> Option<CompressionMethod>
Returns the stored compression method metadata.
Sourcepub fn compression_values(&self) -> CompressionValues
pub fn compression_values(&self) -> CompressionValues
Returns stored compression level and flags metadata.
Sourcepub fn media_type(&self) -> Option<MediaType>
pub fn media_type(&self) -> Option<MediaType>
Returns media type metadata.
Sourcepub fn media_flags(&self) -> MediaFlags
pub fn media_flags(&self) -> MediaFlags
Returns media flag metadata.
Sourcepub fn memory_extents(&self) -> &[MemoryExtent]
pub fn memory_extents(&self) -> &[MemoryExtent]
Returns memory acquisition extents.
Sourcepub fn number_of_memory_extents(&self) -> usize
pub fn number_of_memory_extents(&self) -> usize
Returns the number of memory acquisition extents.
Sourcepub fn memory_extent(&self, index: usize) -> Option<&MemoryExtent>
pub fn memory_extent(&self, index: usize) -> Option<&MemoryExtent>
Returns one memory acquisition extent by index.
Sourcepub fn ewf2_increment_data(&self) -> &[Vec<u8>]
pub fn ewf2_increment_data(&self) -> &[Vec<u8>]
Returns raw EWF2 increment data sections.
Sourcepub fn number_of_ewf2_increment_data_sections(&self) -> usize
pub fn number_of_ewf2_increment_data_sections(&self) -> usize
Returns the number of EWF2 increment data sections.
Sourcepub fn ewf2_increment_data_section(&self, index: usize) -> Option<&[u8]>
pub fn ewf2_increment_data_section(&self, index: usize) -> Option<&[u8]>
Returns one raw EWF2 increment data section by index.
Sourcepub fn ewf2_final_information(&self) -> Option<&[u8]>
pub fn ewf2_final_information(&self) -> Option<&[u8]>
Returns the raw EWF2 final information section.
Sourcepub fn ewf2_restart_data(&self) -> Option<&str>
pub fn ewf2_restart_data(&self) -> Option<&str>
Returns EWF2 restart data text.
Sourcepub fn ewf2_analytical_data(&self) -> Option<&str>
pub fn ewf2_analytical_data(&self) -> Option<&str>
Returns EWF2 analytical data text.
Sourcepub fn header_value(&self, identifier: &str) -> Option<Cow<'_, str>>
pub fn header_value(&self, identifier: &str) -> Option<Cow<'_, str>>
Returns a header value by its EWF identifier.
Sourcepub fn number_of_header_values(&self) -> usize
pub fn number_of_header_values(&self) -> usize
Returns the number of available header values.
Sourcepub fn header_value_identifier(&self, index: usize) -> Option<&str>
pub fn header_value_identifier(&self, index: usize) -> Option<&str>
Returns a 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 stored hash string by identifier.
Sourcepub fn number_of_hash_values(&self) -> usize
pub fn number_of_hash_values(&self) -> usize
Returns the number of stored hash strings.
Sourcepub fn hash_value_identifier(&self, index: usize) -> Option<&str>
pub fn hash_value_identifier(&self, index: usize) -> Option<&str>
Returns a stored hash identifier by enumeration index.
Sourcepub fn cursor(&self) -> ImageCursor ⓘ
pub fn cursor(&self) -> ImageCursor ⓘ
Returns a seekable cursor over the logical media stream.
Sourcepub fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>
pub fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>
Reads logical media bytes at an absolute byte offset.
Returns Ok(0) when buf is empty or offset is at or beyond the
logical media size.
§Errors
Returns an error if chunk lookup, decoding, checksum validation, or
segment I/O fails, or if Image::signal_abort has been called.
Sourcepub fn read_single_file_at(
&self,
entry: &SingleFileEntry,
buf: &mut [u8],
offset: u64,
) -> Result<usize>
pub fn read_single_file_at( &self, entry: &SingleFileEntry, buf: &mut [u8], offset: u64, ) -> Result<usize>
Reads bytes from a logical single-file catalog entry.
Sparse extents read as zeroes. Duplicate-data entries read from their referenced media offset.
§Errors
Returns an error if the entry metadata is inconsistent, the requested
file range is not covered by extents, underlying image reads fail, or
Image::signal_abort has been called.
Sourcepub fn read_file_entry_at(
&self,
entry: &SingleFileEntry,
buf: &mut [u8],
offset: u64,
) -> Result<usize>
pub fn read_file_entry_at( &self, entry: &SingleFileEntry, buf: &mut [u8], offset: u64, ) -> Result<usize>
Alias for Image::read_single_file_at.
§Errors
Returns the same errors as Image::read_single_file_at.
Sourcepub fn root_file_entry(&self) -> Option<&SingleFileEntry>
pub fn root_file_entry(&self) -> Option<&SingleFileEntry>
Returns the root logical single-file entry, if present.
Sourcepub fn file_entry_by_path(&self, path: &str) -> Result<Option<&SingleFileEntry>>
pub fn file_entry_by_path(&self, path: &str) -> Result<Option<&SingleFileEntry>>
Returns a logical single-file entry by path.
§Errors
Returns an error if path contains an empty entry name.
Sourcepub fn source_for_file_entry(
&self,
entry: &SingleFileEntry,
) -> Option<&SingleFileSource>
pub fn source_for_file_entry( &self, entry: &SingleFileEntry, ) -> Option<&SingleFileSource>
Returns the source record associated with a logical single-file entry.
Sourcepub fn subject_for_file_entry(
&self,
entry: &SingleFileEntry,
) -> Option<&SingleFileSubject>
pub fn subject_for_file_entry( &self, entry: &SingleFileEntry, ) -> Option<&SingleFileSubject>
Returns the subject record associated with a logical single-file entry.
Sourcepub fn access_control_entries_for_file_entry(
&self,
entry: &SingleFileEntry,
) -> &[SingleFilePermission]
pub fn access_control_entries_for_file_entry( &self, entry: &SingleFileEntry, ) -> &[SingleFilePermission]
Returns access-control entries associated with a logical single-file entry.
Sourcepub fn number_of_access_control_entries_for_file_entry(
&self,
entry: &SingleFileEntry,
) -> usize
pub fn number_of_access_control_entries_for_file_entry( &self, entry: &SingleFileEntry, ) -> usize
Returns the number of access-control entries for a logical single-file entry.
Sourcepub fn access_control_entry_for_file_entry(
&self,
entry: &SingleFileEntry,
index: usize,
) -> Option<&SingleFilePermission>
pub fn access_control_entry_for_file_entry( &self, entry: &SingleFileEntry, index: usize, ) -> Option<&SingleFilePermission>
Returns one access-control entry for a logical single-file entry by index.
Sourcepub fn acquisition_errors(&self) -> &[AcquisitionError]
pub fn acquisition_errors(&self) -> &[AcquisitionError]
Returns acquisition error ranges.
Sourcepub fn number_of_acquisition_errors(&self) -> usize
pub fn number_of_acquisition_errors(&self) -> usize
Returns the number of acquisition error ranges.
Sourcepub fn acquisition_error(&self, index: usize) -> Option<&AcquisitionError>
pub fn acquisition_error(&self, index: usize) -> Option<&AcquisitionError>
Returns one acquisition error range by index.
Sourcepub fn sessions(&self) -> &[SectorRange]
pub fn sessions(&self) -> &[SectorRange]
Returns session sector ranges.
Sourcepub fn number_of_sessions(&self) -> usize
pub fn number_of_sessions(&self) -> usize
Returns the number of session sector ranges.
Sourcepub fn session(&self, index: usize) -> Option<&SectorRange>
pub fn session(&self, index: usize) -> Option<&SectorRange>
Returns one session sector range by index.
Sourcepub fn tracks(&self) -> &[SectorRange]
pub fn tracks(&self) -> &[SectorRange]
Returns track sector ranges.
Sourcepub fn number_of_tracks(&self) -> usize
pub fn number_of_tracks(&self) -> usize
Returns the number of track sector ranges.
Sourcepub fn track(&self, index: usize) -> Option<&SectorRange>
pub fn track(&self, index: usize) -> Option<&SectorRange>
Returns one track sector range by index.
Sourcepub fn read_zero_chunk_on_error(&self) -> bool
pub fn read_zero_chunk_on_error(&self) -> bool
Returns whether checksum-failed chunks are read as zero-filled data.
Sourcepub fn set_read_zero_chunk_on_error(&self, zero_on_error: bool)
pub fn set_read_zero_chunk_on_error(&self, zero_on_error: bool)
Sets whether checksum-failed chunks are read as zero-filled data.
Sourcepub fn signal_abort(&self)
pub fn signal_abort(&self)
Signals future reads and verification to abort with EwfError::Aborted.
Sourcepub fn checksum_errors(&self) -> Result<Vec<SectorRange>>
pub fn checksum_errors(&self) -> Result<Vec<SectorRange>>
Returns checksum error ranges observed while reading.
§Errors
Returns an error if the internal checksum-error lock is poisoned.
Sourcepub fn number_of_checksum_errors(&self) -> Result<usize>
pub fn number_of_checksum_errors(&self) -> Result<usize>
Returns the number of checksum error ranges observed while reading.
§Errors
Returns an error if the internal checksum-error lock is poisoned.
Sourcepub fn checksum_error(&self, index: usize) -> Result<Option<SectorRange>>
pub fn checksum_error(&self, index: usize) -> Result<Option<SectorRange>>
Returns one checksum error range observed while reading.
§Errors
Returns an error if the internal checksum-error lock is poisoned.
Sourcepub fn single_file_cursor(&self, entry: &SingleFileEntry) -> SingleFileCursor ⓘ
pub fn single_file_cursor(&self, entry: &SingleFileEntry) -> SingleFileCursor ⓘ
Returns a seekable cursor over a logical single-file entry.
Sourcepub fn single_file_cursor_by_path(
&self,
path: &str,
) -> Result<Option<SingleFileCursor>>
pub fn single_file_cursor_by_path( &self, path: &str, ) -> Result<Option<SingleFileCursor>>
Returns a seekable cursor over a logical single-file entry by path.
§Errors
Returns an error if path contains an empty entry name.
Sourcepub fn read_data_chunk(&self, chunk_index: u64) -> Result<DataChunk>
pub fn read_data_chunk(&self, chunk_index: u64) -> Result<DataChunk>
Reads and decodes one logical data chunk.
§Errors
Returns an error if the chunk index is invalid, segment I/O fails,
decoding fails, checksum validation fails under the current policy, or
Image::signal_abort has been called.
Sourcepub fn read_encoded_data_chunk(
&self,
chunk_index: u64,
) -> Result<EncodedDataChunk>
pub fn read_encoded_data_chunk( &self, chunk_index: u64, ) -> Result<EncodedDataChunk>
Reads one encoded data chunk without decoding the payload.
§Errors
Returns an error if the chunk index is invalid, segment I/O fails, or
Image::signal_abort has been called.
Source§impl Image
impl Image
Sourcepub fn verify(&self) -> Result<VerifyResult>
pub fn verify(&self) -> Result<VerifyResult>
Computes streamed MD5 and SHA1 hashes for the logical media stream.
The returned VerifyResult contains computed hashes and optional match
results. Match values are None when the image did not store the
corresponding expected hash.
§Errors
Returns an error if reading the logical media stream fails, if the read
reaches EOF before ImageInfo::logical_size,
or if the image has been aborted with Image::signal_abort.