[][src]Struct dmgwiz::DmgWiz

pub struct DmgWiz<R> {
    pub partitions: Vec<Partition>,
    pub verbosity: Verbosity,
    // some fields omitted
}

Main type representing a DMG

Use the from_reader method to parse a DMG from any input stream. Afterwards, partition information will be available through the partitions attribute. Either extract_all or extract can be used to retrieve partition data from the image.

See main.rs for a real-world example.

Fields

partitions: Vec<Partition>

Array of partitions

verbosity: Verbosity

Implementations

impl<R> DmgWiz<R> where
    R: Read + Seek
[src]

pub fn from_reader(input: R, verbosity: Verbosity) -> Result<DmgWiz<R>>[src]

Create a DmgWiz instance from a seekable byte stream

Arguments

  • input - A seekable reader
  • verbosity - Verbosity for debugging

Example

use std::fs::File;
use dmgwiz::{DmgWiz, Verbosity};

let input = File::open("tests/input_zlib.dmg").unwrap();
let mut wiz = match DmgWiz::from_reader(input, Verbosity::None) {
    Err(err) => panic!(format!("could not read input file - {}", err)),
    Ok(val) => val,
};

pub fn extract_all<W>(&mut self, output: W) -> Result<usize> where
    W: Write + Seek
[src]

Decompress all partitions and write to output

Arguments

  • output - A seekable writer

Example

use std::fs::File;
use dmgwiz::{DmgWiz, Verbosity};

let input = File::open("tests/input_zlib.dmg").unwrap();
let output = File::create("tests/output_zlib.bin").unwrap();
let mut wiz = DmgWiz::from_reader(input, Verbosity::None).unwrap();
match wiz.extract_all(output) {
    Err(err) => panic!(format!("error while extracting: {}", err)),
    Ok(bytes) => println!("done. {} bytes written", bytes),
}

pub fn extract_partition<W>(
    &mut self,
    output: W,
    partition_num: usize
) -> Result<usize> where
    W: Write
[src]

Decompress a specific partition and write to output

Partition information can be retrieved using the partitions attribute of DmzWiz. Returns the number of written bytes.

Arguments

  • output - A writer
  • partition_num - Index of the partition

Example

use std::fs::File;
use dmgwiz::{DmgWiz, Verbosity};

let input = File::open("tests/input_zlib.dmg").unwrap();
let output = File::create("tests/output_zlib.bin").unwrap();
let mut wiz = DmgWiz::from_reader(input, Verbosity::None).unwrap();
match wiz.extract_partition(output, 0) {
    Err(err) => panic!(format!("error while extracting: {}", err)),
    Ok(bytes) => println!("done. {} bytes written", bytes),
}

Auto Trait Implementations

impl<R> RefUnwindSafe for DmgWiz<R> where
    R: RefUnwindSafe

impl<R> Send for DmgWiz<R> where
    R: Send

impl<R> Sync for DmgWiz<R> where
    R: Sync

impl<R> Unpin for DmgWiz<R> where
    R: Unpin

impl<R> UnwindSafe for DmgWiz<R> where
    R: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.