https://github.com/gagath/debcontrol_struct
Automatically parse Debian control files from struct definitions.
https://github.com/gagath/debcontrol_struct
debian
Last synced: 19 days ago
JSON representation
Automatically parse Debian control files from struct definitions.
- Host: GitHub
- URL: https://github.com/gagath/debcontrol_struct
- Owner: gagath
- Created: 2021-08-03T20:35:59.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-07-09T13:53:39.000Z (almost 2 years ago)
- Last Synced: 2025-04-15T15:04:44.603Z (3 months ago)
- Topics: debian
- Language: Rust
- Homepage:
- Size: 42 KB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSES/Apache-2.0.txt
Awesome Lists containing this project
README
# debcontrol_struct
[](https://github.com/MicroJoe/debcontrol_struct/actions/workflows/ci.yml)
[](https://crates.io/crates/debcontrol_struct)
[](https://docs.rs/debcontrol_struct)
[](https://crates.io/crates/debcontrol_struct)
[](https://api.reuse.software/info/github.com/MicroJoe/debcontrol_struct)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:```toml
[dependencies]
debcontrol_struct = "0.3.1"
```## Example
After the crate is installed, you can enjoy the `DebControl` derive!
By defining the following structure:
```rust
use debcontrol::{Paragraph, Field};
use debcontrol_struct::DebControl;#[derive(DebControl)]
struct DerivedStruct {
first: String,
multiple_words: String,
optional: Option,
}
```You can then automatically parse the structure from a debcontrol Paragraph:
```rust
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](LICENSE-APACHE) or [MIT
license](LICENSE-MIT) 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.