16 releases

0.2.0 Oct 26, 2024
0.1.14 Sep 13, 2024
0.1.12 Jul 30, 2024
0.1.11 Mar 9, 2024
0.1.6 Sep 27, 2023

#371 in Parser implementations

Download history 1894/week @ 2024-08-18 2543/week @ 2024-08-25 2092/week @ 2024-09-01 1898/week @ 2024-09-08 793/week @ 2024-09-15 1900/week @ 2024-09-22 1239/week @ 2024-09-29 827/week @ 2024-10-06 1005/week @ 2024-10-13 777/week @ 2024-10-20 836/week @ 2024-10-27 720/week @ 2024-11-03 2442/week @ 2024-11-10 1371/week @ 2024-11-17 735/week @ 2024-11-24 595/week @ 2024-12-01

5,167 downloads per month
Used in 11 crates (9 directly)

Apache-2.0

130KB
3.5K 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

~6–8MB
~131K SLoC