1#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9#[non_exhaustive]
10pub enum SpecError {
11 #[error("empty spec field")]
13 Empty,
14}
15
16#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
18#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
19#[non_exhaustive]
20pub enum FsTypeError {
21 #[error("empty filesystem type (field 3)")]
23 Empty,
24}
25
26#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
28#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
29#[non_exhaustive]
30pub enum OptionsError {
31 #[error("empty option name in mount options")]
33 EmptyOptionName,
34}
35
36#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
38#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
39#[non_exhaustive]
40pub enum OptItemError {
41 #[error("option name must not be empty")]
43 EmptyName,
44}
45
46#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
48#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
49#[non_exhaustive]
50pub enum MountPointError {
51 #[error("mount point must be an absolute path (start with '/') or 'none'")]
53 NotAbsolute,
54 #[error("mount point must not be empty")]
56 Empty,
57}
58
59#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
64#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
65#[non_exhaustive]
66pub enum EntryBuilderError {
67 #[error("missing required field 'spec' in Entry builder")]
69 MissingSpec,
70 #[error("missing required field 'file' (mount point) in Entry builder")]
72 MissingFile,
73 #[error("missing required field 'vfstype' in Entry builder")]
75 MissingFsType,
76}
77
78#[derive(Debug, thiserror::Error)]
80#[non_exhaustive]
81pub enum FstabError {
82 #[error("line {line}: {kind}")]
84 Parse {
85 line: usize,
87 #[source]
89 kind: ParseErrorKind,
90 },
91 #[error("I/O error: {0}")]
93 Io(#[from] std::io::Error),
94 #[error("index {0} out of bounds (len={1})")]
96 IndexOutOfBounds(usize, usize),
97}
98
99#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
101#[non_exhaustive]
102pub enum ParseErrorKind {
103 #[error("missing field: {0}")]
105 MissingField(&'static str),
106 #[error("invalid spec: {0}")]
108 InvalidSpec(#[from] SpecError),
109 #[error("invalid mount point: {0}")]
111 InvalidMountPoint(#[from] MountPointError),
112 #[error("invalid filesystem type: {0}")]
114 InvalidFsType(#[from] FsTypeError),
115 #[error("invalid mount options: {0}")]
117 InvalidOptions(#[from] OptionsError),
118 #[error("invalid freq value: {0}")]
120 InvalidFreq(String),
121 #[error("invalid passno value: {0}")]
123 InvalidPassNo(String),
124}