Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error { UnsupportedFormat(String), UnsupportedCompression { format: &'static str, compression: String, },
#[non_exhaustive]
CorruptFile { what: String, offset: Option<u64>, reason: Option<Box<CorruptReason>>, }, InvalidMetadata(String), CameraUnsupported { make: String, model: String, reason: String, }, GpuUnavailable(String), OutOfMemory(String), LimitExceeded(String), NotAvailable(String), InvalidArgument(String), Io(Error), }
Expand description

All errors produced while parsing or decoding a RAW file.

Errors carry enough context (format, offset, what was being parsed) to make a failure on a corpus file actionable without a debugger.

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.
§

UnsupportedFormat(String)

The bytes do not look like any RAW format FlashRaw understands.

§

UnsupportedCompression

The container was understood but the payload uses an unsupported compression scheme.

Fields

§format: &'static str

Container format name (e.g. "NEF").

§compression: String

Description of the compression scheme.

§

#[non_exhaustive]
CorruptFile

The file is structurally invalid (truncated, bad offsets, corrupt entropy data…).

Truncated sensor data carries a structured CorruptReason (see Error::corrupt_reason and Error::truncation).

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§what: String

What was being parsed or what was wrong.

§offset: Option<u64>

Byte offset in the input where the problem was found, when known.

§reason: Option<Box<CorruptReason>>

Structured cause, when known (e.g. which strip is truncated and by how much).

§

InvalidMetadata(String)

Metadata required for decoding is missing or nonsensical.

§

CameraUnsupported

The file format is supported but this camera or mode is not (yet).

Fields

§make: String

Camera make.

§model: String

Camera model.

§reason: String

Why the camera or mode is unsupported (may be empty).

§

GpuUnavailable(String)

A GPU backend was requested but is not available.

§

OutOfMemory(String)

An allocation would exceed configured limits or failed.

§

LimitExceeded(String)

Image dimensions or other values exceed configured safety limits.

§

NotAvailable(String)

The requested operation is not possible for this file (e.g. no preview, no tiles).

§

InvalidArgument(String)

Invalid caller-provided arguments (bad region, incompatible options…).

§

Io(Error)

I/O failure while reading input.

Implementations§

Source§

impl Error

Source

pub fn corrupt(what: impl Display) -> Self

Shorthand for a Error::CorruptFile without an offset.

Source

pub fn corrupt_at(what: impl Display, offset: u64) -> Self

Shorthand for a Error::CorruptFile with an offset.

Source

pub fn truncated(t: Truncation) -> Self

A Error::CorruptFile for sensor data that extends past the end of the input.

Source

pub fn corrupt_with(reason: CorruptReason) -> Self

A Error::CorruptFile with a structured reason.

Source

pub fn or_truncated( self, file_len: usize, unit: DataUnit, offset: usize, declared: usize, ) -> Self

Attribute a failure to decode a compressed range to truncation when that range (declared bytes at offset) runs past the end of a file_len-byte input: the error becomes a structured CorruptReason::Truncated report. Other errors, and ranges inside the file, are returned unchanged. (Compressed streams are only known to be short when the decoder runs out of data, so the range is not checked up front.)

Source

pub fn corrupt_reason(&self) -> Option<&CorruptReason>

The structured cause of a Error::CorruptFile, when known.

Source

pub fn truncation(&self) -> Option<&Truncation>

Details of truncated sensor data (a CorruptReason::Truncated corruption).

Source

pub fn invalid_metadata(what: impl Display) -> Self

Shorthand for an Error::InvalidMetadata.

Source

pub fn unsupported_compression( format: &'static str, compression: impl Display, ) -> Self

Source

pub fn kind(&self) -> &'static str

Short machine-friendly classification, used by the CLI’s JSON output and the JS bindings.

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

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<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.