15 个版本

新版本 0.1.23 2024 年 8 月 19 日
0.1.21 2024 年 8 月 18 日
0.1.13 2024 年 7 月 16 日
0.1.12 2024 年 6 月 24 日
0.1.4 2023 年 10 月 28 日

#578解析器实现

Download history 698/week @ 2024-05-03 596/week @ 2024-05-10 460/week @ 2024-05-17 408/week @ 2024-05-24 1113/week @ 2024-05-31 1704/week @ 2024-06-07 867/week @ 2024-06-14 1293/week @ 2024-06-21 865/week @ 2024-06-28 787/week @ 2024-07-05 969/week @ 2024-07-12 714/week @ 2024-07-19 1882/week @ 2024-07-26 1466/week @ 2024-08-02 2836/week @ 2024-08-09 2757/week @ 2024-08-16

9,119 每月下载量
用于 10 个 crate (3 直接)

Apache-2.0 许可

55KB
1.5K SLoC

deb822 样式文件的无损解析器

本 crate 包含用于 Debian 中使用的 RFC822 样式文件的无损解析器和编辑器。

基于此 crate 的三个相关 crate 是

  • debian-control
  • debian-copyright
  • dep3

示例

use deb822_lossless::Deb822;
use std::str::FromStr;

let input = r#"Package: deb822-lossless
Maintainer: Jelmer Vernooij <[email protected]>
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);

lib.rs:

deb822 样式文件的无损解析器。

此解析器可以用来解析 deb822 格式的文件,同时保留所有空白和注释。它基于 [rowan] 库,这是一个 Rust 的无损解析库。

一旦解析完成,文件可以被遍历或修改,然后写回文件。

示例

use deb822_lossless::Deb822;
use std::str::FromStr;

let input = r#"Package: deb822-lossless
Maintainer: Jelmer Vernooij <[email protected]>
Homepage: https://github.com/jelmer/deb822-lossless
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);
let homepage = deb822.paragraphs().nth(0).unwrap().get("Homepage");
assert_eq!(homepage.as_deref(), Some("https://github.com/jelmer/deb822-lossless"));

依赖项

~3–5.5MB
~101K SLoC