mount_fstab/lib.rs
1//! # mount-fstab
2//!
3//! A 100% type-safe, memory-safe, thread-safe Rust library for parsing,
4//! editing, validating, and writing `/etc/fstab` files.
5//!
6//! Implements the official fstab(5) semantics from util-linux, aligned with
7//! libmount and glibc parsing behavior.
8//!
9//! ## Quick start
10//!
11//! ```rust
12//! use mount_fstab::Fstab;
13//!
14//! let input = "UUID=root / ext4 defaults 0 1\n";
15//! let fstab = Fstab::parse_str(input).unwrap();
16//! assert_eq!(fstab.entries.len(), 1);
17//! ```
18//!
19//! ## Modules
20//!
21//! | Module | Description |
22//! |--------|-------------|
23//! | [`error`] | Error types for all parsing and validation operations |
24//! | [`escape`] | fstab escape sequence encoding and decoding |
25//! | [`fstype`] | Filesystem type (fstab field 3) |
26//! | [`options`] | Mount options (fstab field 4) with parsing and classification |
27//! | [`parse`] | fstab string and file parsing |
28//! | [`spec`] | Spec/source identifiers (fstab field 1) |
29//! | [`types`] | Core types: `Entry`, `Fstab`, `MountPoint`, `EntryBuilder` |
30//! | [`validate`] | Semantic validation of fstab entries |
31//! | [`mod@write`] | Display formatting and atomic file writing |
32//!
33//! ## Features
34//!
35//! - **Parse**: Full fstab(5) format including all tag types (`LABEL`, `UUID`,
36//! `PARTLABEL`, `PARTUUID`, `ID`), NFS mounts, escape sequences
37//! - **Edit**: Add, remove, replace entries with CRUD API
38//! - **Validate**: Semantic checks matching `findmnt --verify`
39//! - **Serialize**: Display formatting with proper escape encoding
40//! - **Atomic write**: tempfile -> fsync -> rename for safe file updates
41
42#![forbid(unsafe_code)]
43#![deny(missing_docs)]
44#![cfg_attr(docsrs, feature(doc_cfg))]
45
46pub mod error;
47pub mod escape;
48pub mod fstype;
49pub mod options;
50pub mod parse;
51pub mod spec;
52pub mod types;
53pub mod validate;
54pub mod write;
55
56pub use error::{
57 EntryBuilderError, FsTypeError, FstabError, MountPointError, OptItemError, OptionsError,
58 ParseErrorKind, SpecError,
59};
60pub use fstype::FsType;
61pub use options::{MountPermission, OptItem, OptionClass, Options};
62pub use spec::Spec;
63pub use types::{Entry, EntryBuilder, Fstab, MountPoint};
64pub use validate::{Diagnostic, Severity};