[−][src]Crate debcontrol
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
BufParse | A streaming control file parser that buffers input internally. |
Field | A single field in a control file. |
Paragraph | A paragraph in a control file. |
SyntaxError | A parsing syntax error. |
Enums
BufParseError | An error type returned by |
Streaming | A return value from the streaming parser. |
Traits
BufParseInput | A helper trait for stream input. |
Functions
parse_finish | Finish parsing the streaming input and return the final remaining paragraph, if any. |
parse_str | Parse the given complete control file into paragraphs. |
parse_streaming | Attempt to parse a paragraph from the given input. |