Debian Codegraph @

README.md

raw symbols SCIP
1 This crate provides a basic proc-macro for converting a Deb822Paragraph
2 into a Rust struct and vice versa.
3
4 You probably want to use the ``deb822_lossless`` crate instead,
5 with the ``derive`` feature enabled.
6
7 # Example
8
9 ```rust
10 use deb822_lossless::Deb822;
11
12 #[derive(Deb822)]
13 struct Foo {
14 field1: String,
15 field2: Option<String>,
16 }
17
18 let paragraph: deb822::Deb822Paragraph = "field1: value1\nfield2: value2".parse().unwrap();
19 let foo: Foo = paragraph.into();
20 ```
21
22 # Field Formatting Attributes
23
24 The derive macros support field formatting attributes to control how fields are serialized:
25
26 ## `single_line`
27
28 Forces the field value to be on a single line.
29
30 ```rust
31 #[derive(ToDeb822)]
32 struct Package {
33 #[deb822(field = "Package", single_line)]
34 name: String,
35 }
36 ```
37
38 ## `multi_line`
39
40 Ensures continuation lines start with a space character, following deb822 format conventions.
41
42 ```rust
43 #[derive(ToDeb822)]
44 struct Package {
45 #[deb822(field = "Description", multi_line)]
46 description: String,
47 }
48 ```
49
50 ## `folded`
51
52 Strips leading and trailing whitespace from each line and joins them with spaces,
53 implementing RFC 822 folding behavior.
54
55 ```rust
56 #[derive(ToDeb822)]
57 struct Package {
58 #[deb822(field = "Depends", folded)]
59 depends: String,
60 }
61 ```