Crate catconf

source ·
Expand description

Catconf

For when you want:

  1. Runtime configuration for after the binary is compiled
  2. A single file binary

This library allows for taking the final result binary, and just concatenating the configuration to the end:

cat target/debug/binary <(echo -n "CATCONF") conf > confedbinary

Great, but how to get the configuration out and use it in the code? catconf!

It’s use is pretty simple:

use catconf::ConfReaderOptions;

let conf_reader = ConfReaderOptions::new(b"CATCONF".to_vec()).read_from_exe()?;

This returns a Vec<u8> which can be transformed further, by converting to UTF-8 and combined with Serde, decompressing with zlib, etc

Structs

  • Builder struct to allow for configuring the eventual call to read from a file It has two primary properties:

Functions

  • Useful if you just want to read from the current exe without bothering to use the builder
  • Allows for reading for configuration from the end of a file by looking for magic bytes