Skip to main content

apple_mps/
error.rs

1use core::fmt;
2
3/// Errors returned by safe wrapper helpers.
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub enum Error {
6    /// A caller-provided buffer was too small for the requested image transfer.
7    InvalidLength {
8        /// Expected byte count for the requested image transfer.
9        expected: usize,
10        /// Actual byte count supplied by the caller.
11        actual: usize,
12    },
13}
14
15/// Convenient result alias used throughout the crate.
16pub type Result<T> = core::result::Result<T, Error>;
17
18impl fmt::Display for Error {
19    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20        match self {
21            Self::InvalidLength { expected, actual } => {
22                write!(
23                    f,
24                    "buffer too small: expected at least {expected} bytes, got {actual}"
25                )
26            }
27        }
28    }
29}
30
31impl std::error::Error for Error {}