[−][src]Crate superconf
A barebones configuration file made for low-dependency rust applications.
Usage
Add to your Cargo.toml
file:
[dependancies]
superconf = "0.1"
Then you can parse a basic string like so:
use superconf::parse_str; let input = "my_key my_value"; println!("Outputted HashMap: {:#?}", parse_str(input).unwrap());
Example
Here is a complete syntax demonstration:
# comments are like this
# no spaces are allowed in keys or values
# comments can only be at the start of lines, no end of line comments here
# my_key is the key, my_value is the value
my_key the_value
# you can use spaces, just have to be backslashed
your_path /home/user/Cool\ Path/x.txt
Config Conventions
Some conventions commonly used for superconf files:
- The file naming scheme is
snake_case
- All superconf files should end in the
.super
file extension - Try to document each line with a comment
- If commented, space each config part with an empty line seperating it from others. If it is undocumented, you may bunch all config parts together
Motives
Made this as a quick custom parser to challange myself a bit and to use for a quick-n-dirty configuration format in the future. It's not the best file format in the world but it gets the job done.
Enums
SuperError | Primary error enum for superconf, storing the common errors faced. |
Functions
parse_file | Opens a PathBuf-type file and parses contents. |
parse_str | Parses given &str |
parse_string | An alias to the more common parse_str, allowing for easy usage with Strings. |