Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theimpossibleastronaut/configster
Rust library for parsing configuration files
https://github.com/theimpossibleastronaut/configster
config configuration-management library parser rust settings
Last synced: 13 days ago
JSON representation
Rust library for parsing configuration files
- Host: GitHub
- URL: https://github.com/theimpossibleastronaut/configster
- Owner: theimpossibleastronaut
- License: mit
- Created: 2020-07-31T02:08:01.000Z (almost 4 years ago)
- Default Branch: trunk
- Last Pushed: 2024-02-28T05:14:36.000Z (4 months ago)
- Last Synced: 2024-05-18T06:41:30.770Z (about 1 month ago)
- Topics: config, configuration-management, library, parser, rust, settings
- Language: Rust
- Homepage:
- Size: 35.2 KB
- Stars: 19
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog
- License: LICENSE
Lists
- awesome-rust - theimpossibleastronaut/configster - ci.com/theimpossibleastronaut/configster.svg?branch=trunk)](https://travis-ci.com/theimpossibleastronaut/configster) (Libraries / Configuration)
- awesome-rust - theimpossibleastronaut/configster - ci.com/theimpossibleastronaut/configster.svg?branch=trunk)](https://travis-ci.com/theimpossibleastronaut/configster) (Libraries / Configuration)
README
[![Rust-badge]][Rust-url]
[![crates-badge]][crates-url][Rust-badge]: https://github.com/theimpossibleastronaut/configster/actions/workflows/rust.yml/badge.svg
[Rust-url]: https://github.com/theimpossibleastronaut/configster/actions/workflows/rust.yml
[crates-badge]: https://img.shields.io/crates/v/configster.svg
[crates-url]: https://crates.io/crates/configster# configster
Rust library for parsing configuration files
## Config file format
The 'option' can be any string with no whitespace.
```ini
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():```rust
parse_file("./config_test.conf", ',')
``````ini
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.
```ini
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.```rust
#[derive(Debug, PartialEq)]
pub struct Value {
pub primary: String,
pub attributes: Vec,
}#[derive(Debug, PartialEq)]
pub struct OptionProperties {
pub option: String,
pub value: Value,
}
```## Example Code
```rust
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/](https://docs.rs/configster/)
for generated API documentation.