deb822-lossless

Crates.iodeb822-lossless
lib.rsdeb822-lossless
version
sourcesrc
created_at2023-10-28 20:55:31.889171
updated_at2024-11-16 11:37:12.046061
descriptionA lossless parser for deb822 files
homepagehttps://github.com/jelmer/deb822-lossless
repositoryhttps://github.com/jelmer/deb822-lossless
max_upload_size
id1017190
Cargo.toml error:TOML parse error at line 24, column 1 | 24 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Jelmer Vernooij (jelmer)

documentation

README

Parsers and editors for deb822 style files

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

Four related crates that build on this one are:

  • debian-control: A parser and editor for Debian control files, apt lists.
  • debian-copyright: A parser and editor for Debian copyright files.
  • dep3: A parser and editor for Debian DEP-3 headers.
  • r-description: A parser and editor for R DESCRIPTION files.

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);

A derive-macro is also provided for easily defining more Deb822-derived types:

#[cfg(feature = "derive")]
{
use deb822_lossless::{FromDeb822, ToDeb822};

#[derive(FromDeb822, ToDeb822, Debug, PartialEq)]
struct Test {
    #[deb822(field = "Package")]
    package: String,
    architecture: Option<String>,

    #[deb822(field = "Description")]
    description: String,
}

let input = r#"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.
"#;

use deb822_lossless::Paragraph;
use deb822_lossless::convert::FromDeb822Paragraph;
let parser: Paragraph = input.parse().unwrap();
let test: Test = FromDeb822Paragraph::from_paragraph(&parser).unwrap();

assert_eq!(test.package, "deb822-lossless");
}
Commit count: 512

cargo fmt