fast_config
A small, safe, lightweight, and easy-to-use Rust crate to read and write to config files.
Currently only supports: JSON5, TOML, and YAML. But more formats (such as RON) are planned to be added later.
- click here to view code examples - click here to jump to the Getting Started section
What is this crate?
fast_config was made to be a faster to set up, more light-weight, statically typed alternative to config.
It also manages to have its own benefits compared to some other config-reading crates
as there is full support for writing/saving config files,
and it also provides you with some options regarding styling your config files
Why this crate?
- It's small and fast (uses compile-time features to remove/add code)
- It's safe and robust (uses Rust's structs to store data, instead of HashMaps)
- Ridiculously simple to use (only takes 3 lines of short code to make a config file, write/read something, and save it)
Why not this crate?
- It doesn't work if you don't know the way your data will be formatted
(for example if you want your users to be able to have any keys ranging from
key0tokey9000in an object) - It cannot currently understand the RON file format
⚠ Documentation and tests are still being made! ⚠
This crate has now entered the 'stable' stage, i however haven't battle-tested this in any big projects, so while there will NOT be any panics or crashes, some user-side error handling in particular might be a bit bugged
Documentation might be a little weird or incomplete at the current moment, too.
Feel free to contribute any fixes or open up an issue if you find anything that isn't working as it should!
Examples:
use Config;
use ;
// Creating a config struct to store our data
Getting started
- Add the crate to your project via
cargo add fast_config
- Enable the feature(s) for the format(s) you'd like to use
- Currently only
json5,toml, andyamlare supported
- Currently only
- Create a struct to hold your data that derives
serde::Serializeandserde::Deserialize
- Create an instance of your data struct
- Optionally
usethe crate'sConfigtype for convenienceuse fast_config::Config;
- Use
to create and store your config file(s)! Alternatively you could also uselet my_config = new.unwrap;Config::from_settingsto style some things and manually set the format!
View the examples directory for more advanced examples.