[][src]Struct unzpack::Unzpack

pub struct Unzpack;

A library to persist ZIP content bytes into a file and extract its content on file system.

Unzpack is just a helper library which persists ZIP bytes content on file system, then extract its content into a specific directory path and finally deletes current ZIP file. For example, it can be useful when ZIP content is provided via include_bytes! macro.

Implementations

impl Unzpack[src]

pub fn persist<P: AsRef<Path>>(
    zip_bytes: &'static [u8],
    filepath: P
) -> Result<(), Box<dyn Error>>
[src]

Persists Zip content bytes into a .zip file.

Examples

use unzpack::Unzpack;

const ZIP_BYTES: &[u8] = include_bytes!("data/assets.zip");

fn main() -> Result<(), Box<dyn std::error::Error>> {
    Unzpack::persist(ZIP_BYTES, "/tmp/out-file.zip")?;

    Ok(())
}

pub fn extract<P: AsRef<Path>>(
    filepath: P,
    outdir: P
) -> Result<(), Box<dyn Error>>
[src]

Extracts a Zip file into a specific directory. Output directory will be created if doesn't exist.

Examples

use unzpack::Unzpack;

const ZIP_BYTES: &[u8] = include_bytes!("data/assets.zip");

fn main() -> Result<(), Box<dyn std::error::Error>> {
    Unzpack::extract("/tmp/out-file.zip", "/tmp/out-dir")?;

    Ok(())
}

pub fn unpack<P: AsRef<Path>>(
    zip_bytes: &'static [u8],
    out_filepath: P,
    out_dirpath: P
) -> Result<(), Box<dyn Error>>
[src]

Persists and extracts Zip content into specific file system directory.

It persists Zip bytes content into file system as a .zip file, then extract it into a specific directory path and finally the Zip file is deleted.

Examples

use unzpack::Unzpack;

const ZIP_BYTES: &[u8] = include_bytes!("data/assets.zip");

fn main() -> Result<(), Box<dyn std::error::Error>> {
    Unzpack::unpack(
        ZIP_BYTES,          // Zip bytes
        "./out-file.zip",   // Output Zip file
        "./out-dir",        // Output extraction directory
    )?;

    Ok(())
}

Auto Trait Implementations

impl RefUnwindSafe for Unzpack

impl Send for Unzpack

impl Sync for Unzpack

impl Unpin for Unzpack

impl UnwindSafe for Unzpack

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.