Skip to main content

Crate dnf_repofile

Crate dnf_repofile 

Source
Expand description

A pure Rust library for parsing, managing, validating, diffing, and rendering DNF/YUM .repo configuration files.

§Three-Level API

LevelTypePurpose
MacroReposDirManage /etc/yum.repos.d/ directory
MesoRepoFileParse, modify, render a .repo file
MicroRepo, MainConfigType-safe access to individual fields

§Quick Start

use dnf_repofile::{RepoFile, RepoId};

let input = "[epel]\nname=EPEL\nbaseurl=https://example.com/\n";
let rf = RepoFile::parse(input).unwrap();
let block = rf.get(&RepoId::try_new("epel").unwrap()).unwrap();
println!("{}", block.data.name.as_ref().unwrap());

§Features

  • Parse .repo files into fully-typed Rust structs
  • Render back to text with comment/whitespace preservation
  • Validate repository configurations
  • Diff between repo files or individual repos
  • Builder pattern for programmatic creation
  • Variable expansion ($releasever, ${basearch}, etc.)

Re-exports§

pub use builder::RepoBuilder;
pub use diff::diff_files;
pub use diff::diff_main;
pub use diff::diff_repos;
pub use diff::ConfigDiff;
pub use diff::FileDiff;
pub use diff::RepoDiff;
pub use error::Error;
pub use error::Result;
pub use mainconfig::MainConfig;
pub use repo::Repo;
pub use repofile::RawEntry;
pub use repofile::RepoFile;
pub use repofile::SectionBlock;
pub use reposdir::ReposDir;
pub use validate::IssueLevel;
pub use validate::IssueLocation;
pub use validate::ValidationIssue;
pub use validate::ValidationReport;
pub use variables::detect_variables;
pub use variables::expand_variables;
pub use types::*;

Modules§

builder
Builder-pattern API for constructing Repo values.
diff
Diff engine for comparing DNF configuration files and values.
error
Error types for DNF .repo file parsing, validation, and variable expansion.
mainconfig
The DNF [main] configuration section.
repo
The fully typed Repo struct representing a [repo-id] section.
repofile
Parsing, rendering, and manipulation of .repo files.
reposdir
Directory-level management of .repo files on disk.
types
Value types and newtypes for DNF repository configuration options.
validate
Validation engine for checking DNF repository configuration consistency.
variables
Variable detection and expansion for DNF configuration values.