[][src]Function configster::parse_file

pub fn parse_file(
    filename: &str,
    attr_delimit_char: char
) -> Result<Vec<OptionProperties>>

Parses a configuration file. The second parameter sets the delimiter for the attribute list of the primary value. The return value is a vector wrapped in an io::Result type.


Config file format:

ExampleOption = 12

ExampleOption2 = /home/foo/bar, optional, attribute, list, for, value

example_option3 = Hello

# Option = commented_out_using_hashtag

Options Without Values:


Options With the Same Name:

color = Green
color = Blue
color = Black

Accessing the Parsed Data:

use configster::parse_file;
use std::io;

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

    let config_vec = parse_file("./config_test.conf", ',');
    if config_vec.is_err() {
        return io::Result::Err(config_vec.unwrap_err());

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

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