Enum FormatError

Source
pub enum FormatError {
    DirectoryEndSignatureNotFound,
    Directory64EndRecordInvalid,
    DirectoryOffsetPointsOutsideFile,
    InvalidCentralRecord {
        expected: u16,
        actual: u16,
    },
    InvalidExtraField,
    ImpossibleNumberOfFiles {
        claimed_records_count: u64,
        zip_size: u64,
    },
    InvalidLocalHeader,
    InvalidDataDescriptor,
    WrongSize {
        expected: u64,
        actual: u64,
    },
    WrongChecksum {
        expected: u32,
        actual: u32,
    },
}
Expand description

Specific zip format errors, mostly due to invalid zip archives but that could also stem from implementation shortcomings.

Variants§

§

DirectoryEndSignatureNotFound

The end of central directory record was not found.

This usually indicates that the file being read is not a zip archive.

§

Directory64EndRecordInvalid

The zip64 end of central directory record could not be parsed.

This is only returned when a zip64 end of central directory locator was found, so the archive should be zip64, but isn’t.

§

DirectoryOffsetPointsOutsideFile

Corrupted/partial zip file: the offset we found for the central directory points outside of the current file.

§

InvalidCentralRecord

The central record is corrupted somewhat.

This can happen when the end of central directory record advertises a certain number of files, but we weren’t able to read the same number of central directory headers.

Fields

§expected: u16
§actual: u16
§

InvalidExtraField

An extra field (that we support) was not decoded correctly.

This can indicate an invalid zip archive, or an implementation error in this crate.

§

ImpossibleNumberOfFiles

End of central directory record claims an impossible number of file.

Each entry takes a minimum amount of size, so if the overall archive size is smaller than claimed_records_count * minimum_entry_size, we know it’s not a valid zip file.

Fields

§claimed_records_count: u64
§zip_size: u64
§

InvalidLocalHeader

The local file header (before the file data) could not be parsed correctly.

§

InvalidDataDescriptor

The data descriptor (after the file data) could not be parsed correctly.

§

WrongSize

The uncompressed size didn’t match

Fields

§expected: u64
§actual: u64
§

WrongChecksum

The CRC-32 checksum didn’t match.

Fields

§expected: u32
§actual: u32

Trait Implementations§

Source§

impl Debug for FormatError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<FormatError> for Error

Source§

fn from(e: FormatError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.