debcontrol-struct-with-oma-decontrol

Crates.iodebcontrol-struct-with-oma-decontrol
lib.rsdebcontrol-struct-with-oma-decontrol
version0.3.1
sourcesrc
created_at2023-11-20 08:07:38.128845
updated_at2023-11-20 08:07:38.128845
descriptionAutomatic Debian control file parsing for structs.
homepage
repositoryhttps://github.com/eatradish/debcontrol_struct
max_upload_size
id1041846
size27,575
Mag Mell (eatradish)

documentation

README

debcontrol_struct

Build Latest version Documentation License REUSE status

Automatic Debian control file parsing for structs.

Usage

In order to use this crate, you have to add the following dependencies into your project's Cargo.toml file:

[dependencies]
debcontrol_struct = "0.3.1"

Example

After the crate is installed, you can enjoy the DebControl derive!

By defining the following structure:

use debcontrol::{Paragraph, Field};
use debcontrol_struct::DebControl;

#[derive(DebControl)]
struct DerivedStruct {
    first: String,
    multiple_words: String,
    optional: Option<String>,
}

You can then automatically parse the structure from a debcontrol Paragraph:

let input = &debcontrol::parse_str(
    "First: Hello\n\
     Multiple-Words: World\n"
).unwrap()[0];

let derived = DerivedStruct::from_paragraph(&input).unwrap();
assert_eq!("Hello", derived.first);
assert_eq!("World", derived.multiple_words);
assert_eq!(None, derived.optional);

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 26

cargo fmt