#debian #control #dpkg #deb

debcontrol-struct-with-oma-decontrol

为结构体自动解析 Debian 控制文件

1 个不稳定版本

0.3.1 2023年11月20日

#2033解析器实现

MIT/Apache

13KB
245

debcontrol_struct

Build Latest version Documentation License REUSE status

为结构体自动解析 Debian 控制文件。

用法

为了使用此软件包,您必须在项目的 Cargo.toml 文件中添加以下依赖项

[dependencies]
debcontrol_struct = "0.3.1"

示例

安装软件包后,您可以享受 DebControl derive 功能!

通过定义以下结构

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

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

然后可以自动从 debcontrol 段落解析结构

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

许可证

在您选择的情况下,根据 Apache 许可证,版本 2.0MIT 许可证 许可。

除非您明确表示,否则您根据 Apache-2.0 许可证定义的任何有意提交以包含在此项目中并由您提交的贡献,应如上所述双重许可,而不添加任何附加条款或条件。

依赖项

~0.9–1.3MB
~25K SLoC