vfs_zip/
error.rs

1use std::fmt::{self, Debug, Display, Formatter};
2use zip::result::ZipError;
3
4
5
6/// A generic opaque vfs-zip error
7pub struct Error(pub(crate) ZipError);
8// Newtype: I might want to switch away from `zip` in the future to implement
9// multiple file access?  Or bump `zip` versions without breaking semver changes?
10// Either way, this avoids exposing `zip` types directly.
11
12impl Debug   for Error { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { Debug  ::fmt(&self.0, fmt) } }
13impl Display for Error { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { Display::fmt(&self.0, fmt) } }
14impl std::error::Error for Error {}
15impl Error {
16    pub(crate) fn unsupported(s: &'static str) -> Self { Self(ZipError::UnsupportedArchive(s)) }
17}
18
19
20
21/// Shorthand for [std::result::Result]<T, vfs_zip::[Error]>
22pub type Result<T> = std::result::Result<T, Error>;