Struct chd::Chd

source ·
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>

source

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.

source

pub fn header(&self) -> &Header

Returns a reference to the CHD header for this CHD file.

source

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.

source

pub fn metadata(&mut self) -> MetadataEntries<'_, F>

Available on unstable_lending_iterators only.

Returns an iterator over metadata entries for this CHD file.

The contents of each metadata entry are lazily read.

source

pub fn map(&self) -> &Map

Returns the hunk map of this CHD File.

source

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.

source

pub fn get_hunksized_buffer(&self) -> Vec<u8>

Allocates a buffer with the same length as the hunk size of this CHD file.

source

pub fn hunks(&mut self) -> Hunks<'_, F>

Available on unstable_lending_iterators only.

Returns an iterator over the hunks of this CHD file.

source

pub fn into_inner(self) -> (F, Option<Box<Chd<F>>>)

Consumes the Chd and returns the underlying reader and parent if present.

source

pub fn inner(&mut self) -> &mut F

Returns a mutable reference to the inner stream.

source

pub fn inner_parent(&mut self) -> Option<&mut F>

Returns a mutable reference to the inner parent stream if present.

Auto Trait Implementations§

§

impl<F> RefUnwindSafe for Chd<F>
where F: RefUnwindSafe,

§

impl<F> Send for Chd<F>
where F: Send,

§

impl<F> Sync for Chd<F>
where F: Sync,

§

impl<F> Unpin for Chd<F>
where F: Unpin,

§

impl<F> UnwindSafe for Chd<F>
where F: UnwindSafe,

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.