1use core::fmt::Display;
2
3pub type Result<T = ()> = core::result::Result<T, Error>;
4
5#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct Error {
8 pub kind: ErrorKind,
10 pub success_pos: usize,
12}
13
14impl Display for Error {
15 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
16 write!(f, "success pos {}, err:{}", self.success_pos, self.kind)
17 }
18}
19
20impl core::error::Error for Error {}
21
22#[derive(thiserror::Error, Debug, Clone, Copy, PartialEq, Eq)]
24pub enum ErrorKind {
25 #[error("Other error: {0}")]
26 Other(&'static str),
27 #[error("Permission denied")]
28 PermissionDenied,
29 #[error("Hardware not available")]
30 NotAvailable,
31 #[error("Broken pipe")]
32 BrokenPipe,
33 #[error("Invalid parameter: {name}")]
34 InvalidParameter { name: &'static str },
35 #[error("Invalid data")]
36 InvalidData,
37 #[error("Timed out")]
38 TimedOut,
39 #[error("Interrupted")]
43 Interrupted,
44 #[error("Unsupported")]
48 Unsupported,
49 #[error("Out of memory")]
52 OutOfMemory,
53 #[error("Write zero")]
55 WriteZero,
56}