Rust-ConfigParser
⚙ Very simple config parsing lib for rust!
I made this because I just needed a simple config parser for one of my projects and wanted to learn how to make a rust crate. Hopefully you will find it useful as well. :P
💠 Install
Just add the following to your Cargo.toml
:
[]
= "1.0.0"
📀 Quick Start
This config parser is made for use with a simplified version of an ini file. There are no sections and currently no Escape character support.
; This is a comment
# This is also a comment
hello = World
rust = Is great
test = "TEST"
🐳 Why
There are already a few config parsers out there for rust so why use this one?
There are a few reasons:
- It's super simple to use
- Its faster then some other popular config parsers (by only a few hundred Nano seconds but still)
- It's code is easy to understand (For me at least)
- It would make me happy (:P)
💥 Examples
Create a new config from text and a file.
// Import Lib
use Config;
// Create a new config and parse text
let cfg = new
.text
.unwrap;
// Create a new config from a file
let cfg2 = new
.file
.unwrap;
Get a value from a config.
// Import Lib
use Config;
// Create a new config with no file
let cfg = new
.text
.unwrap;
// Get a value from the config (As a string)
println!;
Get value from a config as any type that implements FromStr.
// Import Lib
use Config;
// Create a new config with no file
let mut cfg = new
.text
.unwrap;
// Get a value from the config as bool
assert_eq!;
// Get a value from the config as int
assert_eq!;
// Get a value from the config as float
assert_eq!;