Crates.io | superconf |
lib.rs | superconf |
version | 0.4.3 |
source | src |
created_at | 2020-06-11 03:07:40.825624 |
updated_at | 2020-11-15 14:29:29.574062 |
description | A barebones configuration file made for low-dependency rust applications. |
homepage | |
repository | https://gitlab.com/Owez/superconf |
max_upload_size | |
id | 252585 |
size | 14,885 |
A barebones configuration file made for low-dependency rust applications.
Add to your Cargo.toml
file:
[dependancies]
superconf = "0.4"
Default seperator (space
) demonstration:
use superconf;
let input = "my_key my_value";
println!("{:#?}", superconf::parse(input).unwrap());
Or if you'd like to use a custom seperator like :
or =
:
use superconf::parse_custom_sep;
let input_equal = "custom=seperator";
let input_colon = "second:string";
println!("Equals seperator: {:#?}", parse_custom_sep(input_equal, '=').unwrap());
println!("Colon seperator: {:#?}", parse_custom_sep(input_colon, ':').unwrap());
Here is a complete syntax demonstration:
# comments are like this
# no seperators 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 seperators as plaintext, just have to be backslashed
your_path /home/user/Cool\ Path/x.txt
Some conventions commonly used for superconf files:
snake_case
Made this as a quick custom parser to challenge 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.
Maintaining: This library is now being used inside of my ipeer p2p implementation for all .ipeer
files so maintaining this library is critical.