#[non_exhaustive]pub enum Spec {
Device(PathBuf),
Label(String),
Uuid(String),
PartLabel(String),
PartUuid(String),
Id(String),
NetworkMount {
host: String,
path: PathBuf,
},
Keyword(String),
}Expand description
Filesystem source identifier — fstab(5) field 1.
Corresponds to libmount: fs->source + fs->tagname/fs->tagval.
§Examples
let spec = Spec::parse("UUID=abc-123").unwrap();
assert!(matches!(spec, Spec::Uuid(_)));
assert!(spec.is_tag());Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Device(PathBuf)
Block device path: /dev/sda1, /dev/disk/by-uuid/...
Label(String)
Filesystem label: LABEL=Boot
Uuid(String)
Filesystem UUID: UUID=3e6be9de-... (preserves original case)
PartLabel(String)
GPT partition label: PARTLABEL=System
PartUuid(String)
GPT partition UUID: PARTUUID=...
Id(String)
ID= tag is not strictly defined and depends on udev rules/hardware
Hardware block device ID (deprecated, per fstab(5) and mount(8)).
The ID= tag is not strictly defined and depends on udev rules or
hardware topology. Prefer UUID=, PARTUUID=, or /dev/disk/by-*
paths instead.
NetworkMount
NFS-style network mount: host:/path
Fields
Keyword(String)
Pseudo-filesystem keyword: proc, tmpfs, sysfs, none, etc.
Implementations§
Source§impl Spec
impl Spec
Sourcepub fn parse(raw: &str) -> Result<Self, SpecError>
pub fn parse(raw: &str) -> Result<Self, SpecError>
Parse a decoded spec string into a typed Spec.
This function accepts already-decoded strings. If you need to parse
escape-encoded strings from an fstab file, use parse_raw instead
(crate-internal helper that calls decode_escapes
before parsing).
§Examples
// Device path
let spec = Spec::parse("/dev/sda1").unwrap();
assert!(matches!(spec, Spec::Device(_)));
// Tag-based identifier (case-insensitive tag prefix)
let spec = Spec::parse("uuid=abc-123").unwrap();
assert_eq!(spec, Spec::Uuid("abc-123".into()));
// Label
let spec = Spec::parse("LABEL=Boot").unwrap();
assert_eq!(spec, Spec::Label("Boot".into()));
// NFS network mount
let spec = Spec::parse("server:/export").unwrap();
assert!(matches!(spec, Spec::NetworkMount { .. }));
// Pseudo-filesystem
let spec = Spec::parse("proc").unwrap();
assert!(spec.is_pseudo());§Errors
Returns SpecError::Empty if the input is empty.
Sourcepub fn is_tag(&self) -> bool
pub fn is_tag(&self) -> bool
Returns true if this is a tag-based identifier
(LABEL/UUID/PARTLABEL/PARTUUID/ID).
Sourcepub fn is_pseudo(&self) -> bool
pub fn is_pseudo(&self) -> bool
Returns true if this is a pseudo-filesystem (no backing block device).
Sourcepub fn tag_name(&self) -> Option<&'static str>
pub fn tag_name(&self) -> Option<&'static str>
Returns the tag prefix name for tag-based identifiers.
Returns Some("LABEL"), Some("UUID"), Some("PARTLABEL"),
Some("PARTUUID"), or Some("ID") for tag variants, or None
for non-tag variants.
§Examples
let spec = Spec::parse("UUID=abc-123").unwrap();
assert_eq!(spec.tag_name(), Some("UUID"));
assert_eq!(Spec::parse("/dev/sda1").unwrap().tag_name(), None);Sourcepub fn tag_value(&self) -> Option<&str>
pub fn tag_value(&self) -> Option<&str>
Returns the tag value for tag-based identifiers.
Returns Some(value) for tag variants (e.g., "abc-123" for
UUID=abc-123), or None for non-tag variants.
§Examples
let spec = Spec::parse("LABEL=Boot").unwrap();
assert_eq!(spec.tag_value(), Some("Boot"));
assert_eq!(Spec::parse("proc").unwrap().tag_value(), None);