Crate oma_debcontrol

source ·
Expand description

A crate for parsing Debian control files.

Parse complete input

The parse_str function will parse a complete control file into a vec of Paragraph values:

let paragraphs = parse_str("
a-field: with a value
another-field: with a...
 ...continuation
")?;

assert_eq!(paragraphs, vec![Paragraph {
    fields: vec![
        Field { name: "a-field", value: String::from("with a value") },
        Field { name: "another-field", value: String::from("with a...\n...continuation") }
    ]
}]);

Parse streaming input

The parse_streaming and parse_finish functions can be used to parse a control file incrementally:

let result = parse_streaming("field: value")?;
assert_eq!(result, Streaming::Incomplete);

let result = parse_streaming("field: value\n\n")?;
assert_eq!(result, Streaming::Item(("", Paragraph {
    fields: vec![
        Field { name: "field", value: String::from("value") }
    ]
})));

let result = parse_finish("remaining: input")?;
assert_eq!(result, Some(Paragraph {
    fields: vec![
        Field { name: "remaining", value: String::from("input") }
    ]
}));

Structs

  • A streaming control file parser that buffers input internally.
  • A single field in a control file.
  • A paragraph in a control file.
  • A parsing syntax error.

Enums

Traits

Functions

  • Finish parsing the streaming input and return the final remaining paragraph, if any.
  • Parse the given complete control file into paragraphs.
  • Attempt to parse a paragraph from the given input.