Rust library for parsing configuration files

The 'option' can be any string with no whitespace

configster

Config file format

.

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

Versions

Find the latest versions by id

v0.1.1 - Aug 05, 2020

  • v0.1.1 released (2020-08-05)

  • When an invalid option is encountered, 'InvalidOption_on_Linexx' is assigned to the option (instead of 'InvalidOption').

  • Added get_ver() function. Returns a String containing the library version.

  • Added more docs to the README and the API.

  • Code cleanup

crates-badge

v0.1.0 - Jul 31, 2020

The first version of this library consists of one public function. See https://crates.io/crates/configster for information about adding this crate to your rust project, as well as the API documentation.

Thanks to the rust community (##rust on Freenode and the Rust Community Forum).

crates-badge

Information - Updated Sep 24, 2021

Stars: 19
Forks: 1
Issues: 0

Rust library for Self Organising Maps (SOM)

Add rusticsom as a dependency in Cargo

Rust library for Self Organising Maps (SOM)

Rust library for the Pimoroni Four Letter pHAT

This library aims to port ht16k33 (or rather a fork, as of right now) so credit goes to ht16k33-diet

Rust library for the Pimoroni Four Letter pHAT

Rust library for emulating 32-bit RISC-V

This library can execute instructions against any memory and register file that implements

Rust library for emulating 32-bit RISC-V

Rust library for connecting to the IPFS HTTP API using Hyper/Actix

You can use actix-web as a backend instead of hyper

Rust library for connecting to the IPFS HTTP API using Hyper/Actix

Rust library to manipulate file system access control lists (ACL) on macOS, Linux, and FreeBSD

This module provides two high level functions, getfacl and setfacl

Rust library to manipulate file system access control lists (ACL) on macOS, Linux, and FreeBSD

Rust library translation (rust-src/rust-std/stdlib/rustlib translation)

This is the place to translate Having a documentation in your native language is essential if you don't speak English, and still enjoyable even if...

Rust library translation (rust-src/rust-std/stdlib/rustlib translation)

Rust library for using Infrared hardware decoders (For example a Vishay TSOP* decoder),

enabling remote control support for embedded project

Rust library for using Infrared hardware decoders (For example a Vishay TSOP* decoder),

Rust library for interaction with the OriginTrail Decentralized Knowledge Graph

open up an issue on this repository and let us know

Rust library for interaction with the OriginTrail Decentralized Knowledge Graph

Rust library for parsing COLLADA files

Notice: This library is built around files exported from Blender 2

Rust library for parsing COLLADA files

Rust library for low-level abstraction of MIPS32 processors

This project is licensed under the terms of the MIT license

Rust library for low-level abstraction of MIPS32 processors
Facebook Instagram Twitter GitHub Dribbble
Privacy