Crate dfconfig[−][src]
dfconfig is a lib for parsing and manipulating Dwarf Fortress' init.txt
and d_init.txt
config files (and possibly many others using the same format).
This lib's functionality has been specifically tailored to behave similar as DF internal parser, which implies:
Config::get
returns the last occurrence value, if config specifies the key more than once.- Whitespaces are not allowed at the start of lines, any line not starting with
[
character is treated as a comment.
Other notable functionality is that the parser preserves all of the parsed string content, including blank lines and comments.
Examples
use std::fs::{read_to_string, write}; use dfconfig::Config; // Parse existing config let path = r"/path/to/df/data/init/init.txt"; let mut conf = Config::read_str(read_to_string(path)?); // Read some value let sound = conf.get("SOUND"); // Modify and save the config conf.set("VOLUME", "128"); write(path, conf.print())?;
Structs
Config | The main struct of this crate. Represents DF config file, while also providing functions to parse and manipulate the data. See crate doc for example usage. |