1pub type Result<T> = core::result::Result<T, Error>;
3
4#[derive(Debug, Clone, PartialEq, Eq)]
6pub enum Error {
7InvalidLength { expected: usize, actual: usize },
9OperationFailed(&'static str),
11UnsupportedDataType(u32),
13}
14
15impl core::fmt::Display for Error {
16 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
17 match self {
18 Self::InvalidLength { expected, actual } => {
19 write!(
20 f,
21 "invalid buffer length: expected {expected} bytes, got {actual}"
22 )
23 }
24 Self::OperationFailed(message) => f.write_str(message),
25 Self::UnsupportedDataType(data_type) => {
26 write!(f, "unsupported MPSDataType raw value: {data_type:#x}")
27 }
28 }
29 }
30}
31
32impl std::error::Error for Error {}