ronf/
lib.rs

1//! RONF is a configuration library based on [config-rs](https://github.com/rust-cli/config-rs).
2//!
3//! Configuration is stored in a `Config` structure. It can be created using a builder.
4//! ```rust
5//! use ronf::Config;
6//! let config = Config::builder().build().unwrap();
7//! ```
8//!
9//! On the builder there is a function `add_file(file: File)` which adds a file to read
10//! configuration from.
11//! File can be created with `ronf::File::new("config.json", ronf::FileFormat::Json,
12//! "{\"key\":\"value\"")` or loaded from disk if `read_file` feature is enabled.
13//! ```rust
14//! #[cfg(feature = "json")]
15//! {
16//! use ronf::{Config, File, FileFormat};
17//! let file: File = File::new_str(
18//!     "config.json",
19//!     ronf::FileFormat::Json,
20//!     "{\"key\":\"value\"}",
21//! );
22//! let config = Config::builder()
23//!     .add_file(file)
24//!     .build()
25//!     .unwrap();
26//! println!("\"key\": {}", config.get("key").unwrap());
27//! }
28//! ```
29//!
30//! Check `examples/saves.rs` to see how to save changes to a config.
31
32mod config;
33pub mod error;
34mod file;
35mod format;
36mod value;
37
38pub use crate::config::{Config, ConfigBuilder};
39pub use crate::file::{File, FileFormat};
40pub use crate::value::Value;