dnf-repofile
A 100% pure Rust library for parsing, managing, validating, diffing, and rendering
DNF/YUM .repo configuration files with full round-trip fidelity.
Features
- Parse
.repofiles into fully typed Rust structs (103 DNF options modeled) - Render back to text preserving comments, blank lines, and ordering
- Validate repository configurations (URL sources, GPG consistency, etc.)
- Diff between repo files or individual repositories
- Builder pattern for programmatic creation
- ReposDir for managing a directory of
.repofiles - Variable expansion supporting
$var,${var},${var:-default},${var:+alt}
Usage
use *;
use FromStr;
// Parse a repo file
let input = "\
[epel]
name=Extra Packages for Enterprise Linux
baseurl=https://download.example.com/pub/epel/$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=https://download.example.com/pub/epel/RPM-GPG-KEY
";
let rf = parse?;
// Read options
let block = rf.get.unwrap;
println!;
println!;
// Validate
let report = rf.validate;
assert!;
// Modify
rf.get_mut.unwrap.data.enabled = Some;
// Render back
println!;
// Or use Display
println!;
// Programmatic creation with Builder
let new_repo = new
.name
.baseurl
.gpgcheck
.enabled
.priority
.build;
Three-Level API
| Level | Type | Purpose |
|---|---|---|
| Macro | ReposDir |
Manage a directory of .repo files |
| Meso | RepoFile |
Parse, modify, render a single file |
| Micro | Repo / MainConfig |
Type-safe access to individual options |
License
MIT