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