configparser
A simple configuration parsing utility with no dependencies built on Rust.
configparser
works on a subset of ini configuration syntax (for now). It is inspired by Python's configparser
.
The current release is experimental, this means that future releases will be swift until we reach stable
(1.0.0).
The codebase is thus subject to change for now.
ini-style configuration
Most ini
files look something like this (but they don't need to be .ini
files obviously):
key1 = value1
key2 = value2
key3 = value3
maybekey1aswell = value1
Owing to how ini files usually are, this means that [
, ]
and =
are special symbols (this crate will allow you to use ]
sparingly).
Key-value pairs or section headers cannot spread across multiple lines for obvious reasons because the parser cannot reliably parse it otherwise. A value on the next line could as well be a key for another.
An important note is that key-value pairs not attached to any section are automatically put in a section called DEFAULT
.
Future releases will add support for escaping, comments and modifying default section naming.
Installation
You can install this easily via cargo
by including it in your Cargo.toml
file like:
configparser = "0.3.1"
Usage
You can load an ini
-file easily and parse it like:
use Ini;
use HashMap;
The Ini
struct is the way to go forward and will soon have more features, such as reading from a string, insertion, deletion and variable access.
As of now, there's also a public function, to load an ini-syntax file and parse it into a hashmap. Support for this will be dropped in the near future, and will be changed into a macro when it's dropped.
use ini;
License
Licensed under either of
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
- Lesser General Public license v3.0 (LICENSE-LGPL or https://www.gnu.org/licenses/lgpl-3.0.html)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the LGPL-3.0 license, shall be dual licensed as above, without any additional terms or conditions.
Changelog
- 0.1.0 (yanked)
- First experimental version with only a public-facing load() function.
- 0.1.1
configparser
module renamed toini
.
- 0.2.1
Ini
struct is added along with file-loading, parsing and hashmap functions. Documentation is added.
- 0.2.2
- Fixed docs.
- 0.3.0
- Added
get()
for getting values from the map directly. Docs expanded as well. - Mark
ini::load()
for deprecation.
- Added
Future plans
- Support for
ini::load()
will be dropped in the next major releaser per SemVer (i.e. 1.0.0)- It will be replaced with a macro for a similar functionality.
- It has been marked as deprecated.
- More functions for
Ini
struct, such as reading from a string, insertion, deletion.