| 1 | // Copyright (c) 2021 Harry [Majored] [[email protected]] |
| 2 | // MIT License (https://github.com/Majored/rs-async-zip/blob/main/LICENSE) |
| 3 | |
| 4 | //! A module which holds relevant error reporting structures/types. |
| 5 | |
| 6 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::{Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#, Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#}; |
| 7 | use thiserrorrust-analyzer cargo thiserror 2.0.12 crate/::Errorrust-analyzer cargo thiserror-impl 2.0.12 Error:; |
| 8 | |
| 9 | /// A Result type alias over ZipError to minimise repetition. |
| 10 | pub type Resultrust-analyzer cargo async_zip 0.0.18 error/Result#<V> = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<V, ZipErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError#>; |
| 11 | |
| 12 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 13 | pub enum Zip64ErrorCaserust-analyzer cargo async_zip 0.0.18 error/Zip64ErrorCase# { |
| 14 | TooManyFilesrust-analyzer cargo async_zip 0.0.18 error/Zip64ErrorCase#TooManyFiles#, |
| 15 | LargeFilerust-analyzer cargo async_zip 0.0.18 error/Zip64ErrorCase#LargeFile#, |
| 16 | } |
| 17 | |
| 18 | impl Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Zip64ErrorCaserust-analyzer cargo async_zip 0.0.18 error/Zip64ErrorCase# { |
| 19 | fn fmtrust-analyzer cargo async_zip 0.0.18 error/impl#[Zip64ErrorCase][Display]fmt().(&self, f: &mut Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 20 | match self { |
| 21 | Selfrust-analyzer cargo async_zip 0.0.18 error/impl#[Zip64ErrorCase][Display]::TooManyFilesrust-analyzer cargo async_zip 0.0.18 error/Zip64ErrorCase#TooManyFiles# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "More than 65536 files in archive"), |
| 22 | Selfrust-analyzer cargo async_zip 0.0.18 error/impl#[Zip64ErrorCase][Display]::LargeFilerust-analyzer cargo async_zip 0.0.18 error/Zip64ErrorCase#LargeFile# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "File is larger than 4 GiB"), |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | /// An enum of possible errors and their descriptions. |
| 28 | #[non_exhaustive] |
| 29 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Errorrust-analyzer cargo thiserror-impl 2.0.12 Error:)] |
| 30 | pub enum ZipErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError# { |
| 31 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("feature not supported: '{0}'")] |
| 32 | FeatureNotSupportedrust-analyzer cargo async_zip 0.0.18 error/ZipError#FeatureNotSupported#(&'static str), |
| 33 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("compression not supported: {0}")] |
| 34 | CompressionNotSupportedrust-analyzer cargo async_zip 0.0.18 error/ZipError#CompressionNotSupported#(u16), |
| 35 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("host attribute compatibility not supported: {0}")] |
| 36 | AttributeCompatibilityNotSupportedrust-analyzer cargo async_zip 0.0.18 error/ZipError#AttributeCompatibilityNotSupported#(u16), |
| 37 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("attempted to read a ZIP64 file whilst on a 32-bit target")] |
| 38 | TargetZip64NotSupportedrust-analyzer cargo async_zip 0.0.18 error/ZipError#TargetZip64NotSupported#, |
| 39 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("attempted to write a ZIP file with force_no_zip64 when ZIP64 is needed: {0}")] |
| 40 | Zip64Neededrust-analyzer cargo async_zip 0.0.18 error/ZipError#Zip64Needed#(Zip64ErrorCaserust-analyzer cargo async_zip 0.0.18 error/Zip64ErrorCase#), |
| 41 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("end of file has not been reached")] |
| 42 | EOFNotReachedrust-analyzer cargo async_zip 0.0.18 error/ZipError#EOFNotReached#, |
| 43 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("extra fields exceeded maximum size")] |
| 44 | ExtraFieldTooLargerust-analyzer cargo async_zip 0.0.18 error/ZipError#ExtraFieldTooLarge#, |
| 45 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("comment exceeded maximum size")] |
| 46 | CommentTooLargerust-analyzer cargo async_zip 0.0.18 error/ZipError#CommentTooLarge#, |
| 47 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("filename exceeded maximum size")] |
| 48 | FileNameTooLargerust-analyzer cargo async_zip 0.0.18 error/ZipError#FileNameTooLarge#, |
| 49 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("attempted to convert non-UTF8 bytes to a string/str")] |
| 50 | StringNotUtf8rust-analyzer cargo async_zip 0.0.18 error/ZipError#StringNotUtf8#, |
| 51 | |
| 52 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("unable to locate the end of central directory record")] |
| 53 | UnableToLocateEOCDRrust-analyzer cargo async_zip 0.0.18 error/ZipError#UnableToLocateEOCDR#, |
| 54 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("extra field size was indicated to be {0} but only {1} bytes remain")] |
| 55 | InvalidExtraFieldHeaderrust-analyzer cargo async_zip 0.0.18 error/ZipError#InvalidExtraFieldHeader#(u16, usize), |
| 56 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("zip64 extended information field was incomplete")] |
| 57 | Zip64ExtendedFieldIncompleterust-analyzer cargo async_zip 0.0.18 error/ZipError#Zip64ExtendedFieldIncomplete#, |
| 58 | |
| 59 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("an upstream reader returned an error: {0}")] |
| 60 | UpstreamReadErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError#UpstreamReadError#(#[from] stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#), |
| 61 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("a computed CRC32 value did not match the expected value")] |
| 62 | CRC32CheckErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError#CRC32CheckError#, |
| 63 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("entry index was out of bounds")] |
| 64 | EntryIndexOutOfBoundsrust-analyzer cargo async_zip 0.0.18 error/ZipError#EntryIndexOutOfBounds#, |
| 65 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("Encountered an unexpected header (actual: {0:#x}, expected: {1:#x}).")] |
| 66 | UnexpectedHeaderErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError#UnexpectedHeaderError#(u32, u32), |
| 67 | |
| 68 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("Info-ZIP Unicode Comment Extra Field was incomplete")] |
| 69 | InfoZipUnicodeCommentFieldIncompleterust-analyzer cargo async_zip 0.0.18 error/ZipError#InfoZipUnicodeCommentFieldIncomplete#, |
| 70 | #[errorrust-analyzer cargo thiserror-impl 2.0.12 error:("Info-ZIP Unicode Path Extra Field was incomplete")] |
| 71 | InfoZipUnicodePathFieldIncompleterust-analyzer cargo async_zip 0.0.18 error/ZipError#InfoZipUnicodePathFieldIncomplete#, |
| 72 | } |