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 { expected: usize, actual: usize },
8}
9
10/// Convenient result alias used throughout the crate.
11pub type Result<T> = core::result::Result<T, Error>;
12
13impl fmt::Display for Error {
14    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15        match self {
16            Self::InvalidLength { expected, actual } => {
17                write!(
18                    f,
19                    "buffer too small: expected at least {expected} bytes, got {actual}"
20                )
21            }
22        }
23    }
24}
25
26impl std::error::Error for Error {}