async_zip_futures/
error.rs1use std::fmt::{Display, Formatter};
7use thiserror::Error;
8
9pub type Result<V> = std::result::Result<V, ZipError>;
11
12#[derive(Debug, PartialEq, Eq)]
13pub enum Zip64ErrorCase {
14 TooManyFiles,
15 LargeFile,
16}
17
18impl Display for Zip64ErrorCase {
19 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
20 match self {
21 Self::TooManyFiles => write!(f, "More than 65536 files in archive"),
22 Self::LargeFile => write!(f, "File is larger than 4 GiB"),
23 }
24 }
25}
26
27#[non_exhaustive]
29#[derive(Debug, Error)]
30pub enum ZipError {
31 #[error("feature not supported: '{0}'")]
32 FeatureNotSupported(&'static str),
33 #[error("compression not supported: {0}")]
34 CompressionNotSupported(u16),
35 #[error("host attribute compatibility not supported: {0}")]
36 AttributeCompatibilityNotSupported(u16),
37 #[error("attempted to read a ZIP64 file whilst on a 32-bit target")]
38 TargetZip64NotSupported,
39 #[error("attempted to write a ZIP file with force_no_zip64 when ZIP64 is needed: {0}")]
40 Zip64Needed(Zip64ErrorCase),
41 #[error("end of file has not been reached")]
42 EOFNotReached,
43 #[error("extra fields exceeded maximum size")]
44 ExtraFieldTooLarge,
45 #[error("comment exceeded maximum size")]
46 CommentTooLarge,
47 #[error("filename exceeded maximum size")]
48 FileNameTooLarge,
49
50 #[error("unable to locate the end of central directory record")]
51 UnableToLocateEOCDR,
52 #[error("extra field size was indicated to be {0} but only {1} bytes remain")]
53 InvalidExtraFieldHeader(u16, usize),
54 #[error("zip64 extended information field was incomplete")]
55 Zip64ExtendedFieldIncomplete,
56
57 #[error("an upstream reader returned an error: {0}")]
58 UpstreamReadError(#[from] std::io::Error),
59 #[error("a computed CRC32 value did not match the expected value")]
60 CRC32CheckError,
61 #[error("entry index was out of bounds")]
62 EntryIndexOutOfBounds,
63 #[error("Encountered an unexpected header (actual: {0:#x}, expected: {1:#x}).")]
64 UnexpectedHeaderError(u32, u32),
65}