5 releases

new 0.1.8 Feb 22, 2024
0.1.7 Nov 29, 2023
0.1.6 Nov 28, 2023
0.1.4 Oct 28, 2023
0.1.2 Oct 28, 2023

#644 in Parser implementations

Download history 13/week @ 2023-11-01 31/week @ 2023-11-08 15/week @ 2023-11-15 224/week @ 2023-11-22 690/week @ 2023-11-29 228/week @ 2023-12-06 255/week @ 2023-12-13 642/week @ 2023-12-20 551/week @ 2023-12-27 206/week @ 2024-01-03 188/week @ 2024-01-10 261/week @ 2024-01-17 549/week @ 2024-01-24 228/week @ 2024-01-31 547/week @ 2024-02-07 425/week @ 2024-02-14

1,816 downloads per month
Used in 6 crates (3 directly)

Apache-2.0

35KB
938 lines

Lossless parser for deb822 style files

This crate contains lossless parsers and editors for RFC822 style file as used in Debian.

Three related crates that build on this one are:

  • debian-control
  • debian-copyright
  • dep3

Example

use deb822_lossless::Deb822;
use std::str::FromStr;

let input = r#"Package: deb822-lossless
Maintainer: Jelmer Vernooij <jelmer@debian.org>
Section: rust

Package: deb822-lossless
Architecture: any
Description: Lossless parser for deb822 style files.
  This parser can be used to parse files in the deb822 format, while preserving
  all whitespace and comments. It is based on the [rowan] library, which is a
  lossless parser library for Rust.

"#;

let deb822 = Deb822::from_str(input).unwrap();
assert_eq!(deb822.paragraphs().count(), 2);

lib.rs:

Lossless parser for deb822 style files.

This parser can be used to parse files in the deb822 format, while preserving all whitespace and comments. It is based on the [rowan] library, which is a lossless parser library for Rust.

Once parsed, the file can be traversed or modified, and then written back to a file.

Example

use deb822_lossless::Deb822;
use std::str::FromStr;

let input = r#"Package: deb822-lossless
Maintainer: Jelmer Vernooij <jelmer@debian.org>
Homepage: https://github.com/jelmer/deb822-lossless
Section: rust

Package: deb822-lossless
Architecture: any
Description: Lossless parser for deb822 style files.
  This parser can be used to parse files in the deb822 format, while preserving
  all whitespace and comments. It is based on the [rowan] library, which is a
  lossless parser library for Rust.
"#;

let deb822 = Deb822::from_str(input).unwrap();
assert_eq!(deb822.paragraphs().count(), 2);
let homepage = deb822.paragraphs().nth(0).unwrap().get("Homepage");
assert_eq!(homepage.as_deref(), Some("https://github.com/jelmer/deb822-lossless"));

Dependencies

~3–5MB
~90K SLoC