Skip to main content

Crate alpm_parsers

Crate alpm_parsers 

Source
Expand description

§alpm-parsers

A library for providing various custom parsers/deserializers for the specifications used in Arch Linux Package Management (ALPM).

§Documentation

§Examples

§Custom INI parser

use serde::Deserialize;

const DATA: &str = "
num = 42
text = foo
list = bar
list = baz
list = qux
";

#[derive(Debug, Deserialize)]
struct Data {
    num: u64,
    text: String,
    list: Vec<String>,
}

fn main() {
    let data: Data = alpm_parsers::custom_ini::from_str(DATA).unwrap();
}

The main difference between the regular INI parser and this one is that it allows duplicate keys in a section and collects them into a Vec.

Furthermore, the delimiter must be a =, which is much more rigid than classic ini, as that allows to not use surrounding whitespaces or even other characters as delimiters.

Note: Serde’s flatten attribute is currently not supported. See this issue for more details.

§Features

  • _winnow-debug enables the winnow/debug feature, which shows the exact parsing process of winnow.
  • serde exposes our legacy ini-style serde deserializer. Default: true

§Contributing

Please refer to the contribution guidelines to learn how to contribute to this project.

§License

This project can be used under the terms of the Apache-2.0 or MIT. Contributions to this project, unless noted otherwise, are automatically licensed under the terms of both of those licenses.

Modules§

custom_ini
Custom INI parser.
macros
Macros used with the winnow parser.
traits
Traits used for the parsers.

Macros§

iter_char_context
Take a dyn Iterator<Item = &char> and return a closure that calls .iter() and maps the values onto [winnow::error::StrContextValue::CharLiteral].
iter_str_context
Take an array of dyn Iterator<Item = &'static str> and return a closure that flattens the outer array to map the inner values onto [winnow::error::StrContextValue::StringLiteral].