#[non_exhaustive]pub enum Error {
Show 13 variants
NotAContainer {
found: Vec<u8>,
expected: Vec<u8>,
},
Truncated {
what: &'static str,
needed: u64,
available: u64,
},
UnsupportedFormat {
major: u16,
minor: u16,
supported_major: u16,
},
Reserved {
what: &'static str,
},
SectionOutOfBounds {
id: u32,
offset: u64,
end: u64,
file_len: u64,
},
DuplicateSection {
id: u32,
},
MissingRecord(Tag),
RepeatedRecord(Tag),
UnsupportedRecord {
tag: Tag,
version: u16,
},
DigestMismatch {
what: String,
expected: String,
actual: String,
},
Footer(Error),
TooLarge {
what: &'static str,
needed: u64,
},
Io {
kind: ErrorKind,
detail: String,
},
}Expand description
Why a container could not be read, or could not be trusted once it was read.
Every variant carries enough to put in a log line without going back to the file. An operator who gets one of these should be able to say what is wrong with the dataset without opening a hex editor, because the alternative is that they open a hex editor.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
NotAContainer
The file does not start with the container magic.
Fields
Truncated
The file starts correctly but ends somewhere unexpected.
Fields
UnsupportedFormat
The container was written by a newer major version.
Fields
Reserved
A reserved field was not zero.
Reserved fields are the only place a future version can put a change that older readers must not ignore, so an older reader has to refuse rather than carry on.
SectionOutOfBounds
A section points somewhere that is not inside the payload area.
Fields
DuplicateSection
Two sections claim the same identifier.
MissingRecord(Tag)
A required footer record was missing.
RepeatedRecord(Tag)
A footer record appeared more times than it is allowed to.
UnsupportedRecord
A known footer record was written at a version this build does not read.
DigestMismatch
A digest did not match the bytes it covers.
Fields
The bytes inside the footer did not parse.
TooLarge
Something in the container is bigger than this build can address.
On a 64 bit host this cannot happen. It is here so that a 32 bit host gets a sentence instead of a panic.
Io
Writing a container out did not work.
Only crate::Builder::build_into produces this. Reading never touches a file: a container
is parsed from bytes somebody else fetched, which is what lets the same parser run against a
mapped file, a buffer and a fuzzer’s input.
The kind is kept and the error itself is not, because this enum compares by value and
std::io::Error does not. The kind is the part anybody branches on anyway, and the text is
there for whoever reads the message.
Trait Implementations§
impl Eq for Error
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()