12 releases

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

#249 in Parser implementations

Download history 536/week @ 2024-01-23 217/week @ 2024-01-30 557/week @ 2024-02-06 380/week @ 2024-02-13 400/week @ 2024-02-20 368/week @ 2024-02-27 1121/week @ 2024-03-05 402/week @ 2024-03-12 617/week @ 2024-03-19 745/week @ 2024-03-26 1463/week @ 2024-04-02 308/week @ 2024-04-09 720/week @ 2024-04-16 368/week @ 2024-04-23 650/week @ 2024-04-30 508/week @ 2024-05-07

2,342 downloads per month
Used in 6 crates (4 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

~4.5–6.5MB
~111K SLoC