#[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
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
TypeMismatch
The voxel type does not match the file’s mode.
Fields
BlockShapeMismatch
The data vector length does not match the declared block shape.
Fields
ModeMismatch
The requested voxel type does not match the file’s stored mode.
Fields
InvalidHeaderDetailed(HeaderValidationError)
Detailed header validation failed.
StatsMismatch
Header statistics do not match the actual data.
Fields
Mmap
Memory mapping failed (requires the mmap feature).
FileSizeMismatch
The file size does not match the header’s declared data size.
Fields
NotAVolumeStack
A volume-stack operation was requested on a file that is not a volume stack.
Fields
ValueOutOfRange
A value exceeds the representable range of the target type.
Raised by convert_u16_slice_to_u8
when a u16 value exceeds 255.
Trait Implementations§
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()
Source§impl From<HeaderValidationError> for Error
impl From<HeaderValidationError> for Error
Source§fn from(source: HeaderValidationError) -> Self
fn from(source: HeaderValidationError) -> Self
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> 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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