Crate ronf

Source
Expand description

RONF is a configuration library based on config-rs.

Configuration is stored in a Config structure. It can be created using a builder.

use ronf::Config;
let config = Config::builder().build().unwrap();

On the builder there is a function add_file(file: File) which adds a file to read configuration from. File can be created with ronf::File::new("config.json", ronf::FileFormat::Json, "{\"key\":\"value\"") or loaded from disk if read_file feature is enabled.

#[cfg(feature = "json")]
{
use ronf::{Config, File, FileFormat};
let file: File = File::new_str(
    "config.json",
    ronf::FileFormat::Json,
    "{\"key\":\"value\"}",
);
let config = Config::builder()
    .add_file(file)
    .build()
    .unwrap();
println!("\"key\": {}", config.get("key").unwrap());
}

Check examples/saves.rs to see how to save changes to a config.

Modules§

error

Structs§

Config
Configuration structure to hold parsed values
ConfigBuilder
Builder for the Config struct
File
Representation of a configuration file.

Enums§

FileFormat
Supported file formats.
Value
A type that represents a value in a configuration file.