pub struct Chd<F: Read + Seek> { /* private fields */ }
Expand description
A CHD (MAME Compressed Hunks of Data) file.
Implementations§
source§impl<F: Read + Seek> Chd<F>
impl<F: Read + Seek> Chd<F>
sourcepub fn open(file: F, parent: Option<Box<Chd<F>>>) -> Result<Chd<F>>
pub fn open(file: F, parent: Option<Box<Chd<F>>>) -> Result<Chd<F>>
Open a CHD file from a Read + Seek
stream. Optionally provide a parent of the same stream
type.
The CHD header and hunk map are read and validated immediately.
If the CHD file requires a parent, and a parent is provided, the parent hash is
validated. If hash validation fails, returns Error::InvalidParent
.
If the CHD file does not require a parent, and a parent is provided, returns
Error::InvalidParameter
.
If no parent CHD is provided and the file requires a parent, then the presence of the parent
will not be immediately validated. However, calls to read_hunk_in
will fail with Error::RequiresParent
when a hunk is read that
refers to the parent CHD.
sourcepub fn metadata_refs(&mut self) -> MetadataRefs<'_, F> ⓘ
pub fn metadata_refs(&mut self) -> MetadataRefs<'_, F> ⓘ
Returns an iterator over references to metadata entries for this CHD file.
The contents of each metadata entry are lazily read.
sourcepub fn metadata(&mut self) -> MetadataEntries<'_, F>
Available on unstable_lending_iterators
only.
pub fn metadata(&mut self) -> MetadataEntries<'_, F>
unstable_lending_iterators
only.Returns an iterator over metadata entries for this CHD file.
The contents of each metadata entry are lazily read.
sourcepub fn hunk(&mut self, hunk_num: u32) -> Result<Hunk<'_, F>>
pub fn hunk(&mut self, hunk_num: u32) -> Result<Hunk<'_, F>>
Returns a reference to the given hunk in this CHD file.
If the requested hunk is larger than the number of hunks in the CHD file,
returns Error::HunkOutOfRange
.
sourcepub fn get_hunksized_buffer(&self) -> Vec<u8>
pub fn get_hunksized_buffer(&self) -> Vec<u8>
Allocates a buffer with the same length as the hunk size of this CHD file.
sourcepub fn hunks(&mut self) -> Hunks<'_, F>
Available on unstable_lending_iterators
only.
pub fn hunks(&mut self) -> Hunks<'_, F>
unstable_lending_iterators
only.Returns an iterator over the hunks of this CHD file.
sourcepub fn into_inner(self) -> (F, Option<Box<Chd<F>>>)
pub fn into_inner(self) -> (F, Option<Box<Chd<F>>>)
Consumes the Chd
and returns the underlying reader and parent if present.
sourcepub fn inner_parent(&mut self) -> Option<&mut F>
pub fn inner_parent(&mut self) -> Option<&mut F>
Returns a mutable reference to the inner parent stream if present.