#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub enum SpecError {
#[error("empty spec field")]
Empty,
}
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub enum FsTypeError {
#[error("empty filesystem type (field 3)")]
Empty,
}
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub enum OptionsError {
#[error("empty option name in mount options")]
EmptyOptionName,
}
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub enum OptItemError {
#[error("option name must not be empty")]
EmptyName,
}
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub enum MountPointError {
#[error("mount point must be an absolute path (start with '/') or 'none'")]
NotAbsolute,
#[error("mount point must not be empty")]
Empty,
}
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub enum EntryBuilderError {
#[error("missing required field 'spec' in Entry builder")]
MissingSpec,
#[error("missing required field 'file' (mount point) in Entry builder")]
MissingFile,
#[error("missing required field 'vfstype' in Entry builder")]
MissingFsType,
}
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum FstabError {
#[error("line {line}: {kind}")]
Parse {
line: usize,
#[source]
kind: ParseErrorKind,
},
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("index {0} out of bounds (len={1})")]
IndexOutOfBounds(usize, usize),
}
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
#[non_exhaustive]
pub enum ParseErrorKind {
#[error("missing field: {0}")]
MissingField(&'static str),
#[error("invalid spec: {0}")]
InvalidSpec(#[from] SpecError),
#[error("invalid mount point: {0}")]
InvalidMountPoint(#[from] MountPointError),
#[error("invalid filesystem type: {0}")]
InvalidFsType(#[from] FsTypeError),
#[error("invalid mount options: {0}")]
InvalidOptions(#[from] OptionsError),
#[error("invalid freq value: {0}")]
InvalidFreq(String),
#[error("invalid passno value: {0}")]
InvalidPassNo(String),
}