pub trait SparseFile: Read + Seek {
// Required methods
fn scan_chunks(&mut self) -> Result<Vec<Segment>, ScanError>;
fn drill_hole(&self, start: u64, end: u64) -> Result<(), ScanError>;
}Expand description
An extention trait for File for sparse files
Required Methods§
Sourcefn scan_chunks(&mut self) -> Result<Vec<Segment>, ScanError>
fn scan_chunks(&mut self) -> Result<Vec<Segment>, ScanError>
Scans the file to find its logical chunks
Will return a list of segments, ordered by their start position.
The ranges generated are guaranteed to cover all bytes in the file.
Hole segments are guaranteed to represent a part of a file that does
not contain any non-zero data, however, Data segments may represent
parts of a file that contain what, logically, should be sparse segments.
This is up to the mercy of your operating system and file system, please
consult their documentation for how they handle sparse files for more
details.
Does not make any guarantee about maintaining the Seek position of the file, always seek back to a known point after calling this method.
§Errors
Will return Err(ScanError::UnsupportedPlatform) if support is not
implemented for filesystem level hole finding on your system
Will return Err(ScanError::UnsupportedFileSystem) if support is
implemented for your operating system, but the filesystem does not
support sparse files
Will also return Err if any other I/O error occurs