Enum rc_zip::error::FormatError

source ·
pub enum FormatError {
    DirectoryEndSignatureNotFound,
    Directory64EndRecordInvalid,
    DirectoryOffsetPointsOutsideFile,
    InvalidCentralRecord {
        expected: u16,
        actual: u16,
    },
    InvalidExtraField,
    InvalidHeaderOffset,
    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

expected number of files

§actual: u16

actual number of files

§

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.

§

InvalidHeaderOffset

The header offset of an entry is invalid.

This can indicate an invalid zip archive, or an invalid user-provided global offset

§

ImpossibleNumberOfFiles

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

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

number of files claimed in the end of central directory record

§zip_size: u64

total size of the zip file

§

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

expected size in bytes (from the local header, data descriptor, etc.)

§actual: u64

actual size in bytes (from decompressing the entry)

§

WrongChecksum

The CRC-32 checksum didn’t match.

Fields

§expected: u32

expected checksum (from the data descriptor, etc.)

§actual: u32

actual checksum (from decompressing the entry)

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 Display for FormatError

source§

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

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

impl Error for FormatError

1.30.0 · source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
source§

impl From<FormatError> for Error

source§

fn from(source: 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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more