#[non_exhaustive]pub enum ReadError {
BadMagic,
Truncated {
what: &'static str,
},
Malformed {
what: &'static str,
},
Unsupported {
what: &'static str,
value: u64,
},
LimitExceeded {
limit: &'static str,
},
Invalid(ModelError),
}Expand description
Why bytes could not be read as an object.
Readers are strict: anything the model cannot represent exactly, or that a careful
writer would never produce, is refused rather than guessed at. The enum is
#[non_exhaustive]: match it with a wildcard arm.
§Examples
use object_lang::ReadError;
assert_eq!(object_lang::elf::read(b"MZ\x90\x00"), Err(ReadError::Truncated { what: "file header" }));
assert_eq!(object_lang::elf::read(&[0u8; 64]), Err(ReadError::BadMagic));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
BadMagic
The bytes do not start with the format’s magic number.
Truncated
A structure runs past the end of the input.
Malformed
A field holds a value the format does not allow, or structures contradict each other.
Unsupported
The file is valid but uses something this reader does not support.
Fields
LimitExceeded
A Limits budget was exceeded.
Invalid(ModelError)
The file decodes to an object that breaks a rule of the model.
Trait Implementations§
impl Copy for ReadError
impl Eq for ReadError
Source§impl Error for ReadError
impl Error for ReadError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
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
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<ModelError> for ReadError
impl From<ModelError> for ReadError
Source§fn from(err: ModelError) -> Self
fn from(err: ModelError) -> Self
Converts to this type from the input type.
impl StructuralPartialEq for ReadError
Auto Trait Implementations§
impl Freeze for ReadError
impl RefUnwindSafe for ReadError
impl Send for ReadError
impl Sync for ReadError
impl Unpin for ReadError
impl UnsafeUnpin for ReadError
impl UnwindSafe for ReadError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more