Rust library for parsing configuration files

Overview

Build Status crates-badge

configster

Rust library for parsing configuration files

Config file format

The 'option' can be any string with no whitespace.

arbitrary_option = false
max_users = 30

The value for an option following the equal sign may have "attributes" that are separated by a delimiter. The delimiter is specified when calling parse_file():

parse_file("./config_test.conf", ',')
option = Blue, light, shiny
# option = nothing, void, empty, commented_out

An option is not required to be followed by a value. It can be used to disable a default feature.

FeatureOff

API

Calling parse_file() will return a single vector containing a struct (OptionProperties) for each option line in the config file. The attributes for a value are stored in a vector within the "Value" struct.

#[derive(Debug, PartialEq)]
pub struct Value {
    pub primary: String,
    pub attributes: Vec<String>,
}

#[derive(Debug, PartialEq)]
pub struct OptionProperties {
    pub option: String,
    pub value: Value,
}

Example Code

use std::io;

fn main() -> Result<(), io::Error> {

    let config_vec = configster::parse_file("./config_test.conf", ',')?;

    for i in &config_vec {
        println!("Option:'{}' | value '{}'", i.option, i.value.primary);

        for j in &i.value.attributes {
            println!("attr:'{}`", j);
        }
        println!();
    }
    Ok(())
}

See docs.rs/configster/ for generated API documentation.

Contributing

See CONTRIBUTING.md

You might also like...
A parser combinator for parsing &[Token].

PickTok A parser combinator like nom but specialized in parsing &[Token]. It has similar combinators as nom, but also provides convenient parser gener

Parser for Object files define the geometry and other properties for objects in Wavefront's Advanced Visualizer.

format of the Rust library load locad blender obj file to Rust NDArray. cargo run test\t10k-images.idx3-ubyte A png file will be generated for the fi

A native Rust port of Google's robots.txt parser and matcher C++ library.

robotstxt A native Rust port of Google's robots.txt parser and matcher C++ library. Native Rust port, no third-part crate dependency Zero unsafe code

A parser combinator library for Rust

combine An implementation of parser combinators for Rust, inspired by the Haskell library Parsec. As in Parsec the parsers are LL(1) by default but th

A library to display rich (Markdown) snippets and texts in a rust terminal application
A library to display rich (Markdown) snippets and texts in a rust terminal application

A CLI utilities library leveraging Markdown to format terminal rendering, allowing separation of structure, data and skin. Based on crossterm so works

xml-rs is an XML library for Rust programming language

xml-rs, an XML library for Rust Documentation xml-rs is an XML library for Rust programming language. It is heavily inspired by Java Streaming API for

The Simplest Parser Library (that works) in Rust

The Simplest Parser Library (TSPL) TSPL is the The Simplest Parser Library that works in Rust. Concept In pure functional languages like Haskell, a Pa

Rust parser combinator framework

nom, eating data byte by byte nom is a parser combinators library written in Rust. Its goal is to provide tools to build safe parsers without compromi

A fast monadic-style parser combinator designed to work on stable Rust.

Chomp Chomp is a fast monadic-style parser combinator library designed to work on stable Rust. It was written as the culmination of the experiments de

Comments
  • When

    When "InvalidOption" is assigned, also show line number

    I think it would be a worthwhile improvement if the line number were added to "InvalidOption", such as "InvalidOptionLnn" or "InvalidOptionLine_nn".

    https://github.com/theimpossibleastronaut/configster/blob/96ab97d84ea3b222d88f0d48121fdf94ac08ae58/src/lib.rs#L139-L140

    https://github.com/theimpossibleastronaut/configster/blob/96ab97d84ea3b222d88f0d48121fdf94ac08ae58/src/lib.rs#L95-L96

    enhancement 
    opened by andy5995 0
  • Document the two public structures

    Document the two public structures

    These public structs should be documented

    https://github.com/theimpossibleastronaut/configster/blob/96ab97d84ea3b222d88f0d48121fdf94ac08ae58/src/lib.rs#L5-L15

    documentation 
    opened by andy5995 0
Releases(v0.1.1)
Owner
The Impossible Astronaut
A collection of developers working on some random sources that we like
The Impossible Astronaut
rbdt is a python library (written in rust) for parsing robots.txt files for large scale batch processing.

rbdt ?? ?? ?? ?? rbdt is a work in progress, currently being extracted out of another (private) project for the purpose of open sourcing and better so

Knuckleheads' Club 0 Nov 9, 2021
Universal configuration library parser

LIBUCL Table of Contents generated with DocToc Introduction Basic structure Improvements to the json notation General syntax sugar Automatic arrays cr

Vsevolod Stakhov 1.5k Jan 7, 2023
A Rust library for zero-allocation parsing of binary data.

Zero A Rust library for zero-allocation parsing of binary data. Requires Rust version 1.6 or later (requires stable libcore for no_std). See docs for

Nick Cameron 45 Nov 27, 2022
Yet Another Parser library for Rust. A lightweight, dependency free, parser combinator inspired set of utility methods to help with parsing strings and slices.

Yap: Yet another (rust) parsing library A lightweight, dependency free, parser combinator inspired set of utility methods to help with parsing input.

James Wilson 117 Dec 14, 2022
Parsing Expression Grammar (PEG) parser generator for Rust

Parsing Expression Grammars in Rust Documentation | Release Notes rust-peg is a simple yet flexible parser generator that makes it easy to write robus

Kevin Mehall 1.2k Dec 30, 2022
A typed parser generator embedded in Rust code for Parsing Expression Grammars

Oak Compiled on the nightly channel of Rust. Use rustup for managing compiler channels. You can download and set up the exact same version of the comp

Pierre Talbot 138 Nov 25, 2022
Parsing and inspecting Rust literals (particularly useful for proc macros)

litrs: parsing and inspecting Rust literals litrs offers functionality to parse Rust literals, i.e. tokens in the Rust programming language that repre

Lukas Kalbertodt 31 Dec 26, 2022
A Rust crate for RDF parsing and inferencing.

RDF-rs This crate provides the tools necessary to parse RDF graphs. It currently contains a full (with very few exceptions) Turtle parser that can par

null 2 May 29, 2022
This crate provide parsing fontconfig file but not yet complete all features

This crate provide parsing fontconfig file but not yet complete all features

null 4 Dec 27, 2022
Extensible inline parser engine, the backend parsing engine for Lavendeux.

Lavendeux Parser - Extensible inline parser engine lavendeux-parser is an exensible parsing engine for mathematical expressions. It supports variable

Richard Carson 10 Nov 3, 2022