conf-embed 0.1.1

An experimental Rust crate for embedding user configuration (or anything really) in the executable of the program.
Documentation

conf-embed

An experimental Rust crate for embedding user configuration (or anything really) in the executable of the program.

It pretty much does what the description says. It allows you to get and change some data that is stored in the executable of the program, meaning you don't need to use any additional files to store user configuration.

For example: To use this crate, you would first set a config (this can be any string slice but in this case I am using JSON data):

conf_embed::new_config("{\"arbitrary_data\": \"arbitrary_value\"").unwrap();

When this command is run, a new executable will be produced with the same name as the current one, and the current one will be renamed with .old at the end of it.

For example, if the above code is ran on test.exe, the current test.exe will be renamed to test.exe.old and test.exe will become updated with the new config.

To get the config, simply use:

println!("Current config: '{}'", conf_embed::get_config().unwrap());

This works on all platforms, too.

Also, both functions above return an io::Result<()>, meaning errors can be propagated like such:

use std::io;
use std::process;

fn main() -> io::Result<()> {
	println!("Current config: '{}'", conf_embed::get_config()?);

	println!("Enter a new config:");

	let mut buf = String::new();
	io::stdin().read_line(&mut buf)?;

	println!("Setting new config...");
	conf_embed::new_config(&buf)?;
	println!("Config set, exiting.");
	process::exit(0);
}