Skip to main content

Entry

Struct Entry 

Source
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: Spec

Filesystem source (device, UUID, label, etc.) — fstab(5) field 1.

§file: MountPoint

Mount point path — fstab(5) field 2 (fs_file).

§vfstype: FsType

Filesystem type — fstab(5) field 3 (fs_vfstype).

§options: Options

Mount options — fstab(5) field 4 (fs_mntops).

§freq: u32

Dump frequency — fstab(5) field 5 (fs_freq). Default: 0.

§passno: u32

Filesystem check order — fstab(5) field 6 (fs_passno). Default: 0.

§comment: Option<String>

Comment lines immediately above this entry.

Implementations§

Source§

impl Entry

Source

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());
Source

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());
Source

pub fn is_swap(&self) -> bool

Whether this is a swap entry.

Source

pub fn is_bind_mount(&self) -> bool

Whether this is a bind mount.

Source

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.

Source

pub fn is_network(&self) -> bool

Whether this is a network filesystem.

Source

pub fn comment(&self) -> Option<&str>

Get the comment lines before this entry, if any.

Trait Implementations§

Source§

impl Clone for Entry

Source§

fn clone(&self) -> Entry

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Entry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Entry

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

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.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Entry

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Entry

Source§

fn eq(&self, other: &Entry) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Entry

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Entry

Source§

impl StructuralPartialEq for Entry

Auto Trait Implementations§

§

impl Freeze for Entry

§

impl RefUnwindSafe for Entry

§

impl Send for Entry

§

impl Sync for Entry

§

impl Unpin for Entry

§

impl UnsafeUnpin for Entry

§

impl UnwindSafe for Entry

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,