2 unstable releases

0.2.0 Oct 28, 2021
0.1.0 Aug 11, 2021

#64 in No standard library

Download history 202/week @ 2021-08-11 113/week @ 2021-08-18 93/week @ 2021-08-25 63/week @ 2021-09-01 73/week @ 2021-09-08 131/week @ 2021-09-15 62/week @ 2021-09-22 54/week @ 2021-09-29 36/week @ 2021-10-06 3/week @ 2021-10-13 1/week @ 2021-10-20 143/week @ 2021-10-27 75/week @ 2021-11-03 198/week @ 2021-11-10 47/week @ 2021-11-17 62/week @ 2021-11-24

459 downloads per month
Used in idsp

MIT license

35KB
494 lines

MiniConf

QUARTIQ Matrix Chat Continuous Integration

MiniConf is a no_std minimal run-time settings configuration tool designed to be run on top of any communication means. It was originally designed to work with MQTT clients and provides a default implementation using minimq as the MQTT client.

Design

Miniconf provides an easy-to-work-with API for quickly adding runtime-configured settings to any embedded project. This allows any internet-connected device to quickly bring up configuration interfaces with minimal implementation in the end-user application.

MiniConf provides a Miniconf derive macro for creating a settings structure, e.g.:

use miniconf::Miniconf;

#[derive(Miniconf)]
struct NestedSettings {
    inner: f32,
}

#[derive(Miniconf)]
struct MySettings {
    initial_value: u32,
    internal: NestedSettings,
}

Settings Paths

A setting value must be configured via a specific path. Paths take the form of variable names separated by slashes - this design follows typical MQTT topic design semantics. For example, with the following Settings structure:

#[derive(Miniconf)]
struct Data {
    inner: f32,
}

#[derive(Miniconf)]
struct Settings {
    initial_value: u32,
    internal: Data,
}

We can access Data::inner with the path internal/inner.

Settings may only be updated at the terminal node. That is, you cannot configure <device-id>/settings/internal directly. If this is desired, instead derive MiniconfAtomic on the struct Data definition. In this way, all members of struct Data must be updated simultaneously.

Settings Values

MiniConf relies on using serde for defining a de/serialization method for settings. Currently, MiniConf only supports serde-json de/serialization formats, although more formats may be supported in the future.

Dependencies

~1.1–2MB
~45K SLoC

\za