33 releases

0.1.38 Oct 7, 2024
0.1.28 Aug 27, 2024
0.1.13 Jul 16, 2024
0.1.8 Feb 22, 2024
0.1.1 Jun 16, 2023

#2282 in Parser implementations

Download history 877/week @ 2024-07-13 655/week @ 2024-07-20 2430/week @ 2024-07-27 2133/week @ 2024-08-03 2101/week @ 2024-08-10 3016/week @ 2024-08-17 2963/week @ 2024-08-24 2374/week @ 2024-08-31 3218/week @ 2024-09-07 1193/week @ 2024-09-14 2063/week @ 2024-09-21 1612/week @ 2024-09-28 991/week @ 2024-10-05 710/week @ 2024-10-12 865/week @ 2024-10-19 703/week @ 2024-10-26

3,309 downloads per month
Used in 8 crates (7 directly)

Apache-2.0

1MB
8K SLoC

Lossless parser for Debian Control files

This crate provides a parser for Debian control files. It is lossless, meaning that it will preserve the original formatting of the file. It also provides a way to serialize the parsed data back to a string.

use debian_control::{Control, Priority};
use std::fs::File;

let mut control = Control::new();
let mut source = control.add_source("hello");
source.set_section("rust");

let mut binary = control.add_binary("hello");
binary.set_architecture("amd64");
binary.set_priority(Priority::Optional);
binary.set_description("Hello, world!");

assert_eq!(control.to_string(), r#"Source: hello
Section: rust

Package: hello
Architecture: amd64
Priority: optional
Description: Hello, world!
"#);

lib.rs:

Parser for Debian control files.

This crate provides a parser for Debian control files.

Example

use debian_control::lossy::Control;
use debian_control::fields::Priority;
use std::fs::File;

let mut control = Control::new();
let mut source = &mut control.source;
source.name = "hello".to_string();
source.section = Some("rust".to_string());

let mut binary = control.add_binary("hello");
binary.architecture = Some("amd64".to_string());
binary.priority = Some(Priority::Optional);
binary.description = Some("Hello, world!".to_string());

assert_eq!(control.to_string(), r#"Source: hello
Section: rust

Package: hello
Architecture: amd64
Priority: optional
Description: Hello, world!
"#);

See the lossless module for a parser that preserves all comments and formatting, and as well as allowing inline errors.

Dependencies

~7–9.5MB
~185K SLoC