6 releases
0.2.7 | Apr 19, 2022 |
---|---|
0.2.6 | Apr 15, 2022 |
0.1.5 | Apr 14, 2022 |
#1686 in Parser implementations
13KB
252 lines
INIp
📝 An INI parser library written in Rust.
Summary
Features
Feature | Implemented? |
---|---|
Sections support | ✔️ |
Disabled entry recognition | ✔️ |
Section nesting support | ❌ |
Multi-line support | ❌ |
Installation
Add this to your Cargo.toml
:
inip = "0.2.7"
Example
; file.ini
[section]
full_name = "Hicaro"
use inip::Parser;
fn main() {
let parsed_file = Parser::parse("file.ini").unwrap();
assert_eq!(parsed_file["section"]["full_name"], "Hicaro".to_string());
}
You can read valid and invalid examples on examples
.
Rules
-
Comment lines start with
;
or it should be the first non-whitespace character of the line.; this is a comment ; This is another comment # this is not a comment
-
All values must be surrounded by quotes
Valid:
[section] name = "John Doe"
Invalid:
[section] name = John Doe
-
All key names must have one word
Valid:
[credentials] full_name = "John Doe"
Invalid:
[credentials] full name = "John Doe"
If you want multiple words on your key name, use whatever style you want, but don't use space to separate that.
-
Disable entry recognition by using
;
[credentials] ; full_name = "John Doe"
Contributions
If you find any problems with this library, please let me know by opening an issue explaining the problem.
License
This project is licensed under the MIT license.