mount-fstab 0.1.1

Type-safe /etc/fstab parsing, editing, and validation library
Documentation
# mount-fstab

[![Crates.io](https://img.shields.io/crates/v/mount-fstab.svg)](https://crates.io/crates/mount-fstab)
[![Documentation](https://docs.rs/mount-fstab/badge.svg)](https://docs.rs/mount-fstab)
[![CI](https://github.com/franckcl1989/mount-fstab/workflows/CI/badge.svg)](https://github.com/franckcl1989/mount-fstab/actions)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![MSRV](https://img.shields.io/badge/MSRV-1.95-red.svg)](https://blog.rust-lang.org/2025/02/20/Rust-1.95.0.html)

A 100% type-safe, memory-safe, thread-safe Rust library for parsing,
editing, validating, and writing `/etc/fstab` files.

Implements the official fstab(5) semantics from util-linux, aligned with
libmount and glibc parsing behavior.

## Quick Start

```rust
use mount_fstab::{Entry, Fstab, FsType, MountPoint, Options, Spec};

// Parse an fstab file
let input = "\
# /etc/fstab
UUID=abc-123 / ext4 defaults 0 1
UUID=def-456 /boot ext4 defaults 0 2
/swap.img none swap sw 0 0
";
let fstab = Fstab::parse_str(input).unwrap();

// Inspect entries
assert_eq!(fstab.len(), 3);
let root = fstab.root().unwrap();
assert!(root.file.is_root());

// Edit entries
let mut fstab = Fstab::parse_str(input).unwrap();
fstab
    .add(Entry::builder()
        .spec(Spec::parse("UUID=data").unwrap())
        .file(MountPoint::new("/data").unwrap())
        .vfstype(FsType::parse("ext4").unwrap())
        .options(Options::parse("defaults,noatime").unwrap())
        .build()
        .unwrap())
    .remove(1); // Remove /boot

// Validate
for diag in fstab.validate() {
    eprintln!("{:?}: {}", diag.severity, diag.message);
}

// Atomic write
fstab.write_atomic("/etc/fstab").unwrap();
```

## Features

- **Parse** -- Full fstab(5) format: all tag types (LABEL, UUID, PARTLABEL,
  PARTUUID, ID), NFS mounts, escape sequences, comments
- **Edit** -- CRUD API with order preservation and comment tracking
- **Validate** -- Semantic checks matching `findmnt --verify`
- **Serialize** -- `Display` formatting with proper escape encoding
- **Atomic write** -- `tempfile -> fsync -> rename` for safe file updates
- **Type safety** -- Every field is a validated type, not a raw string
- **serde** -- Optional Serialize/Deserialize support

## Installation

```toml
[dependencies]
mount-fstab = "0.1"
```

For serde support:

```toml
[dependencies]
mount-fstab = { version = "0.1", features = ["serde"] }
```

## Minimum Supported Rust Version

Rust 1.95 or later.

## License

Licensed under the MIT license. See [LICENSE](LICENSE) for details.