#rfc822 #debian #serde


RFC822-like encoding used in conrol files implemented for serde

4 releases

0.2.1 Dec 20, 2021
0.2.0 Dec 13, 2021
0.1.1 Dec 13, 2021
0.1.0 Aug 5, 2021

#698 in Encoding

Download history 28/week @ 2023-08-16 43/week @ 2023-08-23 40/week @ 2023-08-30 46/week @ 2023-09-06 50/week @ 2023-09-13 17/week @ 2023-09-20 41/week @ 2023-09-27 46/week @ 2023-10-04 35/week @ 2023-10-11 52/week @ 2023-10-18 135/week @ 2023-10-25 164/week @ 2023-11-01 152/week @ 2023-11-08 109/week @ 2023-11-15 49/week @ 2023-11-22 88/week @ 2023-11-29

424 downloads per month
Used in 2 crates (via assorted-debian-utils)

MITNFA license

1.5K SLoC

Rust library for handling RFC822-like format used in Debian


This crate implements the file format inpired by RFC822 that is used in Debian packages. It is the format of the debian/control files in packages and Packages file of apt. It is called rfc822-like instead of just rfc822 because Debian does not claim to implement RFC822 exactly and this crate is focused on working with Debian tools, not parsing exact RFC822 file format. Frankly, I didn't even bother to read RFC822 itself.

If you need to strictly parse RFC822, I suggest you to fork this crate and fix whatever differences there are. I'm not interested in maintaining strict RFC822 crate, so don't send PRs for that but I'm willing to put common pieces into their own crate. If you're interested in this approach feel free to file a PR (or ask beforehand if you have questions).

Note that this crate is currently not optimized for performance. There are multiple places where allocation could be avoided and other optimizations may be missing. It's absolutely fine for my own use cases, and probably will be for yours as well. If you need it to be faster or just want to have fun improving its performance I'll be happy to accept PRs.

The API is currently not set in stone and may change over time. Basic steps to minimize the impact of changes were taken (e.g. encapsulation of Error type).


Check the crate documentation for more examples and detailed explanation.

use rfc822_like::de::Deserializer;
use serde::Deserialize;

let input = "Package: foo
Description: The Foo

Package: bar
Description: The Bar

let mut reader = input.as_bytes();

#[derive(Debug, Eq, PartialEq, serde_derive::Deserialize)]
#[serde(rename_all = "PascalCase")]
struct Record {
    package: String,
    description: String,

let expected = vec![
    Record {
        package: "foo".to_owned(),
        description:"The Foo".to_owned(),
    Record {
        package: "bar".to_owned(),
        description: "The Bar".to_owned(),

let deserialized = <Vec<Record>>::deserialize(Deserializer::new(&mut reader)).unwrap();
assert_eq!(deserialized, expected);


Whatever Rust version is available in the latest Debian stable, currently 1.41.1.




~34K SLoC