Crate miniconf[−][src]
Expand description
Miniconf
Miniconf is a a lightweight utility to manage run-time configurable settings.
Overview
Miniconf uses a Derive macro to automatically assign unique paths to each setting. All values are transmitted and received in JSON format.
Supported Protocols
Miniconf is designed to be protocol-agnostic. Any means that you have of receiving input from some external source can be used to acquire paths and values for updating settings.
While Miniconf is platform agnostic, there is an MQTT-based client provided to manage settings via the MQTT protocol.
Example
use miniconf::{Miniconf, MiniconfAtomic}; use serde::Deserialize; #[derive(Deserialize, MiniconfAtomic, Default)] struct Coefficients { forward: f32, backward: f32, } #[derive(Deserialize, Miniconf, Default)] struct Settings { filter: Coefficients, channel_gain: [f32; 2], sample_rate: u32, force_update: bool, } fn main() { let mut settings = Settings::default(); // Update sample rate. miniconf::update(&mut settings, "sample_rate", b"350").unwrap(); // Update filter coefficients. miniconf::update(&mut settings, "filter", b"{\"forward\": 35.6, \"backward\": 0.0}").unwrap(); // Update channel gain for channel 0. miniconf::update(&mut settings, "channel_gain/0", b"15").unwrap(); }
Limitations
Minconf cannot be used with some of Rust’s more complex types. Some unsupported types:
- Complex enums
- Tuples
Re-exports
pub use minimq;
pub use serde_json_core;
Structs
MQTT settings interface.
Enums
Errors that occur during settings configuration
Traits
A data structure that can be deserialized from any data format supported by Serde.
A data structure that can be deserialized without borrowing any data from the deserializer.
Functions
Convenience function to update settings directly from a string path and data.
Derive Macros
Derive the Miniconf trait for custom types.
Derive the Miniconf trait for a custom type that must be updated atomically.