#[non_exhaustive]pub enum ImageError {
NotAnImage,
Format(u16),
Corrupt,
Invalid,
}Expand description
Why bytes could not be loaded as a language image.
§Examples
use lang_forge::{ImageError, Language};
assert_eq!(Language::from_image(b"not an image").unwrap_err(), ImageError::NotAnImage);
let lang = Language::from_lsf("[language]\nname = \"x\"\n[rules]\nx = \"NUMBER\"\n")?;
let mut image = lang.to_image();
let last = image.len() - 1;
image[last] ^= 0xFF;
assert_eq!(Language::from_image(&image).unwrap_err(), ImageError::Corrupt);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.
NotAnImage
The bytes do not start with the image header.
Format(u16)
The image is of a format this lang-forge does not read. Re-forge the sketch.
Corrupt
The image is truncated, or its body does not match its hash.
Invalid
The image’s hash matches, but its tables are not ones lang-forge builds: an index out of range, a malformed automaton, or invalid text. It was not written by this lang-forge.
Trait Implementations§
Source§impl Clone for ImageError
impl Clone for ImageError
impl Copy for ImageError
Source§impl Debug for ImageError
impl Debug for ImageError
Source§impl Display for ImageError
impl Display for ImageError
impl Eq for ImageError
Source§impl Error for ImageError
impl Error for ImageError
1.30.0 · 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 Hash for ImageError
impl Hash for ImageError
Source§impl PartialEq for ImageError
impl PartialEq for ImageError
impl StructuralPartialEq for ImageError
Auto Trait Implementations§
impl Freeze for ImageError
impl RefUnwindSafe for ImageError
impl Send for ImageError
impl Sync for ImageError
impl Unpin for ImageError
impl UnsafeUnpin for ImageError
impl UnwindSafe for ImageError
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