pub struct Entry {
pub spec: Spec,
pub file: MountPoint,
pub vfstype: FsType,
pub options: Options,
pub freq: u32,
pub passno: u32,
pub comment: Option<String>,
}Expand description
A single fstab entry — corresponds to libmount struct libmnt_fs.
Each entry represents one line in /etc/fstab, consisting of six
whitespace-separated fields plus an optional preceding comment block.
§Examples
let entry = Entry {
spec: Spec::parse("UUID=root").unwrap(),
file: MountPoint::new("/").unwrap(),
vfstype: FsType::parse("ext4").unwrap(),
options: Options::parse("defaults").unwrap(),
freq: 0,
passno: 1,
comment: None,
};
assert!(entry.is_root());Fields§
§spec: SpecFilesystem source (device, UUID, label, etc.) — fstab(5) field 1.
file: MountPointMount point path — fstab(5) field 2 (fs_file).
vfstype: FsTypeFilesystem type — fstab(5) field 3 (fs_vfstype).
options: OptionsMount options — fstab(5) field 4 (fs_mntops).
freq: u32Dump frequency — fstab(5) field 5 (fs_freq). Default: 0.
passno: u32Filesystem check order — fstab(5) field 6 (fs_passno). Default: 0.
comment: Option<String>Comment lines immediately above this entry.
Implementations§
Source§impl Entry
impl Entry
Sourcepub fn new(
spec: Spec,
file: MountPoint,
vfstype: FsType,
options: Options,
) -> Self
pub fn new( spec: Spec, file: MountPoint, vfstype: FsType, options: Options, ) -> Self
Create a new entry with the required fields.
freq and passno default to 0, and comment defaults to None.
§Examples
let entry = Entry::new(
Spec::parse("UUID=root").unwrap(),
MountPoint::new("/").unwrap(),
FsType::parse("ext4").unwrap(),
Options::parse("defaults").unwrap(),
);
assert!(entry.file.is_root());
assert_eq!(entry.freq, 0);
assert_eq!(entry.passno, 0);
assert!(entry.comment.is_none());Sourcepub fn builder() -> EntryBuilder
pub fn builder() -> EntryBuilder
Create an EntryBuilder for ergonomic construction with optional fields.
§Examples
let entry = Entry::builder()
.spec(Spec::parse("UUID=root").unwrap())
.file(MountPoint::new("/").unwrap())
.vfstype(FsType::parse("ext4").unwrap())
.options(Options::parse("defaults,noatime").unwrap())
.freq(0)
.passno(1)
.comment("# Root filesystem")
.build()
.unwrap();
assert!(entry.is_root());Sourcepub fn is_bind_mount(&self) -> bool
pub fn is_bind_mount(&self) -> bool
Whether this is a bind mount.
Sourcepub fn is_root(&self) -> bool
pub fn is_root(&self) -> bool
Whether this is the root filesystem entry.
Returns true only when the mount point is / and passno == 1,
following the fstab(5) convention that the root filesystem must have
fs_passno set to 1. An entry at / with passno != 1 is not
considered the root entry by this method.
Sourcepub fn is_network(&self) -> bool
pub fn is_network(&self) -> bool
Whether this is a network filesystem.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Entry
impl<'de> Deserialize<'de> for Entry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for Entry
Format an Entry as an fstab data line.
impl Display for Entry
Format an Entry as an fstab data line.
The output includes the spec (with escape encoding), mount point
(with escape encoding), filesystem type, and options. If either
freq or passno is non-zero, both are included.