12 releases

0.1.11 Mar 9, 2024
0.1.10 Oct 5, 2023
0.1.6 Sep 27, 2023

#332 in Parser implementations

Download history 837/week @ 2024-03-24 1120/week @ 2024-03-31 910/week @ 2024-04-07 418/week @ 2024-04-14 636/week @ 2024-04-21 370/week @ 2024-04-28 622/week @ 2024-05-05 649/week @ 2024-05-12 433/week @ 2024-05-19 831/week @ 2024-05-26 1053/week @ 2024-06-02 1045/week @ 2024-06-09 740/week @ 2024-06-16 1042/week @ 2024-06-23 653/week @ 2024-06-30 924/week @ 2024-07-07

3,386 downloads per month
Used in 7 crates (5 directly)

Apache-2.0

110KB
3K SLoC

Debian Changelog parser

This crate provides a parser for debian/changelog files, as described in the Debian policy, section 4.4.

The parser builds a CST. It is lossless - i.e. preserves formatting, and allows editing and partial parsing.

Example:


use std::io::Read;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let file = std::fs::File::open("/usr/share/doc/rustc/changelog.Debian.gz")?;
    let mut gz = flate2::read::GzDecoder::new(file);
    let mut contents = String::new();
    gz.read_to_string(&mut contents)?;
    let changelog: debian_changelog::ChangeLog = contents.parse()?;
    for entry in changelog.entries() {
        println!(
            "{}: {}",
            entry.package().unwrap(),
            entry.version().unwrap().to_string()
        );
    }
    Ok(())
}

Or to update an existing changelog file:


use std::io::Read;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let file = std::fs::File::open("debian/changelog")?;
    let mut contents = String::new();
    file.read_to_string(&mut contents)?;
    let changelog: debian_changelog::ChangeLog = contents.parse()?;
    changelog.auto_add_change(
        &["* Make a change"],
        (
            "Jelmer Vernooij".to_string(),
            "jelmer@debian.org".to_string(),
        ),
        None,
        None,
    );
    std::fs::write("debian/changelog", changelog.to_string())?;
    Ok(())
}

Dependencies

~5–7MB
~112K SLoC