corevm_host/fs/
error.rs

1/// Generic file system error.
2#[derive(Debug)]
3pub enum Error {
4	/// Invalid file block.
5	Block,
6	/// Input/output error.
7	Io,
8	/// Invalid node kind.
9	Node,
10	/// Path resolution error.
11	Path,
12	/// File system loop.
13	Loop,
14}
15
16impl core::fmt::Display for Error {
17	fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
18		core::fmt::Debug::fmt(self, f)
19	}
20}
21
22#[cfg(any(feature = "std", test))]
23impl std::error::Error for Error {}
24
25impl From<InvalidBlock> for Error {
26	fn from(_: InvalidBlock) -> Self {
27		Self::Block
28	}
29}
30
31impl From<IoError> for Error {
32	fn from(_: IoError) -> Self {
33		Self::Io
34	}
35}
36
37/// Invalid file block.
38#[derive(Debug)]
39pub struct InvalidBlock;
40
41impl core::fmt::Display for InvalidBlock {
42	fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
43		core::fmt::Debug::fmt(self, f)
44	}
45}
46
47#[cfg(any(feature = "std", test))]
48impl std::error::Error for InvalidBlock {}
49
50/// Path resolution error.
51#[derive(Debug)]
52pub struct InvalidPath;
53
54impl core::fmt::Display for InvalidPath {
55	fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
56		core::fmt::Debug::fmt(self, f)
57	}
58}
59
60#[cfg(any(feature = "std", test))]
61impl std::error::Error for InvalidPath {}
62
63/// Input/output error.
64#[derive(Debug)]
65pub struct IoError;
66
67impl core::fmt::Display for IoError {
68	fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
69		core::fmt::Debug::fmt(self, f)
70	}
71}
72
73#[cfg(any(feature = "std", test))]
74impl std::error::Error for IoError {}