1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum NtfsReaderError {
5 #[error("elevation error")]
6 ElevationError,
7 #[error("io error")]
8 IOError(#[from] std::io::Error),
9 #[error("binread error")]
10 BinReadError(#[from] binread::error::Error),
11 #[error("windows error")]
12 WindowsError(#[from] WindowsErrorWrapper),
13 #[error("missing required MFT attribute: {0}")]
14 MissingMftAttribute(String),
15 #[error("unknown")]
16 Unknown,
17}
18
19#[derive(Debug)]
20pub struct WindowsErrorWrapper(windows::core::Error);
21impl WindowsErrorWrapper {
22 pub fn from_thread() -> WindowsErrorWrapper {
23 WindowsErrorWrapper(windows::core::Error::from_thread())
24 }
25}
26
27impl std::fmt::Display for WindowsErrorWrapper {
28 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
29 write!(f, "Windows error: {}", self.0)
30 }
31}
32impl std::error::Error for WindowsErrorWrapper {}
33
34pub type NtfsReaderResult<T> = core::result::Result<T, NtfsReaderError>;