epub_builder/zip.rs
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with
3// this file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5use std::io::Read;
6use std::io::Write;
7use std::path::Path;
8
9use crate::Result;
10
11/// An abstraction over possible Zip implementations.
12///
13/// The actual implementations are `ZipCommand` (uses the system command zip) or
14/// `ZipLibrary` (uses the [Rust zip library](https://crates.io/crates/zip)).
15pub trait Zip {
16 /// Write the source content to a file in the archive
17 fn write_file<P: AsRef<Path>, R: Read>(&mut self, file: P, content: R) -> Result<()>;
18
19 /// Generate the ZIP file
20 fn generate<W: Write>(self, _: W) -> Result<()>;
21}