Skip to content

Commit

Permalink
make ZipHandler constructor public
Browse files Browse the repository at this point in the history
  • Loading branch information
patochectp committed Jan 24, 2022
1 parent 6f11bef commit d18eb0d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/file_handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,20 @@ pub struct ZipHandler<R: Seek + Read> {
index_by_name: BTreeMap<String, usize>,
}

/// ZipHandler is used to read files from an archive
impl<R> ZipHandler<R>
where
R: Seek + Read,
{
pub(crate) fn new<P: AsRef<Path>>(r: R, path: P) -> Result<Self> {
/// Constructs a new ZipHandler
pub fn new<P: AsRef<Path>>(r: R, path: P) -> Result<Self> {
let mut archive = zip::ZipArchive::new(r)?;
Ok(ZipHandler {
index_by_name: Self::files_by_name(&mut archive),
archive,
archive_path: path.as_ref().to_path_buf(),
})
}

fn files_by_name(archive: &mut zip::ZipArchive<R>) -> BTreeMap<String, usize> {
(0..archive.len())
.filter_map(|i| {
Expand Down

0 comments on commit d18eb0d

Please sign in to comment.