extract

Function extract 

Source
pub fn extract<P, R>(destination: P, reader: R) -> Result<Report, Error>
where P: AsRef<Path>, R: Read + Seek,
Expand description

Extract from a reader with default settings.

This is the “just works” convenience API. It creates the destination directory if it doesn’t exist. For more control, use Extractor directly.

§Destination Creation

Unlike Extractor::new, this function creates the destination directory if it doesn’t exist. This is convenient but means typos like /var/uplaods will silently create a wrong directory. For user-facing code where you want to catch such errors, use Extractor::new instead.

§Seekable Reader Required

The reader must implement std::io::Seek because zip files store the central directory at the end. For non-seekable streams, buffer into a std::io::Cursor first.

§Example

use std::io::Cursor;
use safe_unzip::extract;

let zip_bytes = std::fs::read("archive.zip")?;
let report = extract("/var/uploads", Cursor::new(zip_bytes))?;