Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 13 variants Io(Error), InvalidHeader, UnsupportedMode, BoundsError { offset: Option<[usize; 3]>, shape: Option<[usize; 3]>, volume: Option<[usize; 3]>, }, TypeMismatch { expected: usize, actual: usize, }, BlockShapeMismatch { expected: usize, actual: usize, }, ModeMismatch { file_mode: Mode, requested_mode: Mode, offset: Option<[usize; 3]>, }, InvalidHeaderDetailed(HeaderValidationError), StatsMismatch { claimed_dmin: f32, claimed_dmax: f32, claimed_dmean: f32, claimed_rms: f32, actual_dmin: f32, actual_dmax: f32, actual_dmean: f32, actual_rms: f32, }, Mmap, FileSizeMismatch { expected: usize, actual: usize, }, NotAVolumeStack { ispg: i32, mz: i32, }, ValueOutOfRange { value: u64, max: u64, },
}
Expand description

The top-level error type for MRC I/O operations.

Most fallible functions in this crate return Result<T, Error>.

This enum is #[non_exhaustive] — new variants may be added in minor releases without breaking exhaustive matches. Use a wildcard arm (_) when matching all variants.

§Example — constructing and displaying an error

use mrc::Error;

let err = Error::InvalidHeader;
assert_eq!(err.to_string(), "Invalid MRC header");

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

Io(Error)

An underlying I/O operation failed.

§

InvalidHeader

The MRC header is malformed or fails basic validation.

§

UnsupportedMode

The MRC mode value is not supported by this crate.

§

BoundsError

A requested read or write falls outside the volume bounds.

The optional fields provide context about which block was requested and what the volume dimensions were.

Fields

§offset: Option<[usize; 3]>

Offset of the requested block [x, y, z].

§shape: Option<[usize; 3]>

Shape of the requested block [sx, sy, sz].

§volume: Option<[usize; 3]>

Dimensions of the volume [nx, ny, nz].

§

TypeMismatch

The voxel type does not match the file’s mode.

Fields

§expected: usize

Number of bytes per voxel expected by the decoder.

§actual: usize

Number of bytes provided.

§

BlockShapeMismatch

The data vector length does not match the declared block shape.

Fields

§expected: usize

Number of elements expected from the shape.

§actual: usize

Number of elements actually provided.

§

ModeMismatch

The requested voxel type does not match the file’s stored mode.

Fields

§file_mode: Mode

The mode stored in the file.

§requested_mode: Mode

The mode requested by the caller.

§offset: Option<[usize; 3]>

Offset where the mismatch was detected [x, y, z].

§

InvalidHeaderDetailed(HeaderValidationError)

Detailed header validation failed.

§

StatsMismatch

Header statistics do not match the actual data.

Fields

§claimed_dmin: f32

Minimum density value claimed in the header.

§claimed_dmax: f32

Maximum density value claimed in the header.

§claimed_dmean: f32

Mean density value claimed in the header.

§claimed_rms: f32

RMS deviation claimed in the header.

§actual_dmin: f32

Actual minimum density computed from the data.

§actual_dmax: f32

Actual maximum density computed from the data.

§actual_dmean: f32

Actual mean density computed from the data.

§actual_rms: f32

Actual RMS deviation computed from the data.

§

Mmap

Memory mapping failed (requires the mmap feature).

§

FileSizeMismatch

The file size does not match the header’s declared data size.

Fields

§expected: usize

Expected file size in bytes (header + extended header + data).

§actual: usize

Actual file size in bytes.

§

NotAVolumeStack

A volume-stack operation was requested on a file that is not a volume stack.

Fields

§ispg: i32

The ISPG (space group) value from the header.

§mz: i32

The MZ (sampling along Z) value from the header.

§

ValueOutOfRange

A value exceeds the representable range of the target type.

Raised by convert_u16_slice_to_u8 when a u16 value exceeds 255.

Fields

§value: u64

The value that exceeded the range.

§max: u64

The maximum allowed value for the target type.

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

impl From<Error> for Error

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<HeaderValidationError> for Error

Source§

fn from(source: HeaderValidationError) -> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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