Crates.io | configster |
lib.rs | configster |
version | 0.1.1 |
source | src |
created_at | 2020-07-31 02:39:33.846056 |
updated_at | 2020-08-05 18:16:03.53215 |
description | Rust library for parsing configuration files |
homepage | https://github.com/theimpossibleastronaut/configster |
repository | |
max_upload_size | |
id | 271525 |
size | 15,036 |
Rust library for parsing configuration files
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
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,
}
/// 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.
See CONTRIBUTING.md