Skip to main content

dnf_repofile/
lib.rs

1//! A pure Rust library for parsing, managing, validating, diffing,
2//! and rendering DNF/YUM `.repo` configuration files.
3//!
4//! # Three-Level API
5//!
6//! | Level  | Type                       | Purpose                               |
7//! |--------|----------------------------|---------------------------------------|
8//! | Macro  | [`ReposDir`]               | Manage `/etc/yum.repos.d/` directory  |
9//! | Meso   | [`RepoFile`]               | Parse, modify, render a `.repo` file  |
10//! | Micro  | [`Repo`], [`MainConfig`]   | Type-safe access to individual fields |
11//!
12//! # Quick Start
13//!
14//! ```
15//! use dnf_repofile::{RepoFile, RepoId};
16//!
17//! let input = "[epel]\nname=EPEL\nbaseurl=https://example.com/\n";
18//! let rf = RepoFile::parse(input).unwrap();
19//! let block = rf.get(&RepoId::try_new("epel").unwrap()).unwrap();
20//! println!("{}", block.data.name.as_ref().unwrap());
21//! ```
22//!
23//! # Features
24//!
25//! - **Parse** `.repo` files into fully-typed Rust structs
26//! - **Render** back to text with comment/whitespace preservation
27//! - **Validate** repository configurations
28//! - **Diff** between repo files or individual repos
29//! - **Builder** pattern for programmatic creation
30//! - **Variable expansion** (`$releasever`, `${basearch}`, etc.)
31
32pub mod builder;
33pub mod diff;
34pub mod error;
35pub mod mainconfig;
36pub mod repo;
37pub mod repofile;
38pub mod reposdir;
39pub mod types;
40pub mod validate;
41pub mod variables;
42
43// Re-export key types for convenience
44pub use builder::RepoBuilder;
45pub use diff::{diff_files, diff_main, diff_repos, ConfigDiff, FileDiff, RepoDiff};
46pub use error::{Error, Result};
47pub use mainconfig::MainConfig;
48pub use repo::Repo;
49pub use repofile::{RawEntry, RepoFile, SectionBlock};
50pub use reposdir::ReposDir;
51pub use types::*;
52pub use validate::{IssueLevel, IssueLocation, ValidationIssue, ValidationReport};
53pub use variables::{detect_variables, expand_variables};