Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing develop with main #119

Merged
merged 184 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
184 commits
Select commit Hold shift + click to select a range
8bbf2ed
Adding support for calling custom validation function on settings update
ryan-summers Dec 7, 2021
c6999c8
Adding support for handled settings updates
ryan-summers Dec 7, 2021
a865892
Updating CHANGELOG
ryan-summers Dec 7, 2021
777c51d
Merge branch 'develop' into feature/settings-validation
ryan-summers Dec 7, 2021
3eacf3c
Merge branch 'develop' into feature/settings-validation
ryan-summers Dec 10, 2021
b118bd4
Reverting MQTT example changes
ryan-summers Dec 10, 2021
cc4e6ef
Adding integration test for settings validation failure
ryan-summers Dec 10, 2021
e99efa0
Merge branch 'main' into feature/settings-validation
ryan-summers Dec 14, 2021
28feb80
Fixing tests
ryan-summers Dec 14, 2021
653d3c7
Refactoring validation
ryan-summers Dec 15, 2021
cab3ee8
change dir to match repo structure
nkrackow Jan 19, 2022
7d7f8f2
Merge pull request #73 from quartiq/py_readme_fix
ryan-summers Jan 19, 2022
affdbf7
Updating MqttClient to accept initial settings values
ryan-summers Jan 27, 2022
ea5c961
Merge branch 'develop' into feature/non-default-settings
ryan-summers Jan 27, 2022
9347677
Merge pull request #75 from quartiq/feature/non-default-settings
ryan-summers Jan 27, 2022
5e21760
Simplifying design
ryan-summers Feb 2, 2022
bb413e3
Adding support for Options
ryan-summers Feb 2, 2022
f35acb5
Updating changelog
ryan-summers Feb 2, 2022
020e525
Reformatting
ryan-summers Feb 2, 2022
2268a18
Fixing test
ryan-summers Feb 3, 2022
5a0afac
Merge pull request #77 from quartiq/feature/optional-settings
ryan-summers Feb 3, 2022
483435b
Merge branch 'develop' into feature/settings-validation
ryan-summers Feb 3, 2022
aa2fc0a
Beefing up docs around handled updates
ryan-summers Feb 3, 2022
d8aaebd
Updating error management
ryan-summers Feb 3, 2022
4f0ea7c
Removing republish timeout reset, fixing tests
ryan-summers Feb 3, 2022
148f092
Updating CHANGELOG
ryan-summers Feb 3, 2022
94825b6
Merge pull request #63 from quartiq/feature/settings-validation
ryan-summers Feb 3, 2022
3c12735
Implementing fix to ignore incoming republish data
ryan-summers Feb 14, 2022
d3df914
Fixing tests, includes, etc.
ryan-summers Feb 14, 2022
fb0708e
Fixing various clippy lints
ryan-summers Feb 14, 2022
78c4dc0
Moving MqttClient source code
ryan-summers Feb 14, 2022
b3d3b00
Refactoring iter API
ryan-summers Feb 14, 2022
1678788
Merge pull request #83 from quartiq/feature/clippy
jordens Feb 14, 2022
434a2ce
Merge branch 'develop' into rs/issue-71/ignore-republish
ryan-summers Feb 14, 2022
a62a6cc
Bumping dependency
ryan-summers Feb 14, 2022
6845fc2
Fixing imports
ryan-summers Feb 14, 2022
dbdfbe2
Fixing format
ryan-summers Feb 14, 2022
b560a69
Addressing clippy lints
ryan-summers Feb 16, 2022
140b6f3
Merge pull request #82 from quartiq/rs/issue-71/ignore-republish
jordens Feb 16, 2022
00a91b1
Preparing for miniconf release
ryan-summers May 11, 2022
206864b
Merge pull request #85 from quartiq/release/v0.4.0
ryan-summers May 11, 2022
cc60587
Renaming iterator functions to prevent name conflicts
ryan-summers May 12, 2022
6a827c3
Fixing docs
ryan-summers May 12, 2022
dc90729
fixing format
ryan-summers May 12, 2022
7c4d7f7
Merge pull request #89 from quartiq/rs/issue-87/iter-rename
ryan-summers May 12, 2022
a527c7e
Staging 0.5.0 miniconf release
ryan-summers May 12, 2022
bff1003
Merge pull request #90 from quartiq/release/v0.5.0
ryan-summers May 12, 2022
f605684
py: remove whitespace on dump
jordens Jul 7, 2022
8b09f2a
Merge branch 'develop' into rj/json-separators-whitespace
ryan-summers Jul 7, 2022
82bd461
add changelog entry
jordens Jul 12, 2022
98438ab
Merge pull request #92 from quartiq/rj/json-separators-whitespace
ryan-summers Jul 12, 2022
3aa3d76
Refactoring to support latest minimq
ryan-summers Sep 8, 2022
d4d8197
Removing correlation data from republish
ryan-summers Sep 8, 2022
b431eed
Removing old file
ryan-summers Sep 8, 2022
d450aec
add string without macro
nkrackow Oct 13, 2022
febc615
Updating discovery to discover unique devices only
ryan-summers Oct 19, 2022
97c63ab
Updating changelog
ryan-summers Oct 19, 2022
0ac710e
Updating string impl
ryan-summers Oct 19, 2022
801f3ac
Fixing format
ryan-summers Oct 19, 2022
6be26f7
Adding vec support
ryan-summers Oct 19, 2022
4641099
Updating set semantics
ryan-summers Oct 19, 2022
90eea76
Merge pull request #98 from quartiq/feature/unique-discovery
ryan-summers Oct 19, 2022
50405ec
Removing vec support
ryan-summers Oct 19, 2022
e10ff4b
Merge branch 'develop' into nk/heapless-strings
ryan-summers Oct 19, 2022
d57464c
Forcing repoll on GHA
ryan-summers Oct 19, 2022
3a07a7f
Merge pull request #96 from quartiq/nk/heapless-strings
ryan-summers Oct 19, 2022
2e2a86a
Refactoring trait API
ryan-summers Oct 28, 2022
9c5f6fd
Fixing publicity
ryan-summers Oct 28, 2022
7f4407b
Fixing format
ryan-summers Oct 28, 2022
776460b
Reverting options
ryan-summers Oct 28, 2022
e74c03e
Adding nested array test
ryan-summers Oct 28, 2022
39b647b
Updating arrays to be defer-by-default
ryan-summers Oct 28, 2022
b656c0f
Fixing optional support
ryan-summers Oct 28, 2022
e909fe7
Updating CHANGELOG
ryan-summers Oct 28, 2022
f8d524a
Fixing test
ryan-summers Oct 28, 2022
9453dad
fixing style
ryan-summers Oct 28, 2022
9913e67
Simplifying derives
ryan-summers Oct 28, 2022
e04f4e6
Simplifying bounds on integration test
ryan-summers Oct 28, 2022
28293a1
Cleaning up python client
ryan-summers Oct 28, 2022
bcd15f1
Updating CHANGELOG
ryan-summers Oct 28, 2022
b35489d
Removing request_id
ryan-summers Oct 28, 2022
0480267
Updating API to ignore responses with unknwon request IDs
ryan-summers Oct 28, 2022
009c1ed
Adding command timeout
ryan-summers Oct 28, 2022
60bb82e
simplifying log
ryan-summers Oct 28, 2022
18ea343
Updating CHANGELOG
ryan-summers Oct 28, 2022
6770955
Fixing CHANGELOG
ryan-summers Oct 28, 2022
9714bd5
Updating pop API
ryan-summers Oct 28, 2022
945ef45
Merge pull request #101 from quartiq/rs/python-client
ryan-summers Oct 28, 2022
ea2d673
minor refactorings
jordens Oct 31, 2022
04d4cea
iter: rename generics a bit
jordens Nov 1, 2022
312d44a
mqtt state machine: silence clippy warning
jordens Nov 1, 2022
a616769
API renaming
jordens Nov 1, 2022
341f732
array fixup
jordens Nov 1, 2022
a0c34f6
Update src/array.rs
ryan-summers Nov 1, 2022
ae57c74
Update src/option.rs
ryan-summers Nov 1, 2022
1db5ee5
Merge branch 'develop' into feature/trait-rework
ryan-summers Nov 1, 2022
9187fd6
Updating arrays/options naming
ryan-summers Nov 1, 2022
4974c84
Merge branch 'feature/trait-rework' of github.com:quartiq/miniconf in…
ryan-summers Nov 1, 2022
aeb94d6
Fixing docs
ryan-summers Nov 1, 2022
5dea652
Merge branch 'feature/trait-rework' into pr/ryan-summers/100
ryan-summers Nov 1, 2022
59ffbca
Update CHANGELOG.md
ryan-summers Nov 1, 2022
5e79215
Merge remote-tracking branch 'origin/feature/trait-rework' into pr/ry…
jordens Nov 1, 2022
45dd9e1
address review comments
jordens Nov 1, 2022
a3c8fe1
Merge remote-tracking branch 'origin/feature/trait-rework' into pr/ry…
jordens Nov 1, 2022
af77ed2
Merge remote-tracking branch 'origin/pr/ryan-summers/100' into pr/rya…
jordens Nov 1, 2022
a75181f
Merge pull request #100 from quartiq/feature/trait-rework
jordens Nov 1, 2022
6652e4e
Merge branch 'develop' into pr/ryan-summers/100
jordens Nov 1, 2022
960548f
Update docs, clean up names
jordens Nov 1, 2022
3f9bca4
option: remove unnecessary bounds
jordens Nov 1, 2022
5b739c9
nits
jordens Nov 1, 2022
63c79dd
Update src/lib.rs
jordens Nov 1, 2022
0bf2d85
rm AtomicUpdateRequired Error and mark things non_exhaustive
jordens Nov 1, 2022
4adec14
reword intro
jordens Nov 1, 2022
46e6129
Merge pull request #102 from quartiq/pr/ryan-summers/100
ryan-summers Nov 1, 2022
f2082e3
make set-path generic over Peekable
jordens Nov 1, 2022
07fca66
make get_path generic over Peekable
jordens Nov 1, 2022
0513908
pass the path iter down as mutable ref, simplify unittests
jordens Nov 1, 2022
b716d60
rm unnecessary bound
jordens Nov 1, 2022
2a58465
mqtt: use set() api
jordens Nov 1, 2022
21bb9b0
docstrings
jordens Nov 1, 2022
c595a88
simplify next_path assembly logic
jordens Nov 1, 2022
b7f0039
fix deferred option, add unittest
jordens Nov 1, 2022
d0ce7cb
clean up metadata and next_path
jordens Nov 2, 2022
6eab83e
make metadata an associated function
jordens Nov 2, 2022
d13e21e
return bytes consumed from
jordens Nov 2, 2022
1323134
make next_path an associated function (always include Option)
jordens Nov 2, 2022
6f864ba
make iter_paths, unchecked_iter_paths associated functions
jordens Nov 2, 2022
622fae2
check for runtime presence of topics on iteration
jordens Nov 2, 2022
cfe8c19
add changelog entries
jordens Nov 2, 2022
5eac0b7
Apply suggestions from code review
jordens Nov 2, 2022
b27e8fc
docstrings: add update from review
jordens Nov 2, 2022
3e86bf5
iter fields don't need to be pub
jordens Nov 2, 2022
5df05d4
add specific PathAbsent error for runtime absence
jordens Nov 2, 2022
d3e6da4
remove redundant comment
jordens Nov 2, 2022
bc71f56
Merge pull request #105 from quartiq/rj/generic-path
ryan-summers Nov 2, 2022
1c002e1
symmetric error
jordens Nov 2, 2022
8b94874
Merge pull request #108 from quartiq/rj/ser-error
jordens Nov 2, 2022
c4b3afe
next_path: return Err(IterError) instead of unreachable
jordens Nov 2, 2022
3e420e2
add path count to Metadata
jordens Nov 2, 2022
f791c19
impl size_hint
jordens Nov 2, 2022
b579296
docstring additions
jordens Nov 2, 2022
35679f4
Merge branch 'develop' into feature/minimq-update
ryan-summers Nov 3, 2022
8735232
Updating smlang and minimq
ryan-summers Nov 3, 2022
23d95fa
docstrings, review suggestions
jordens Nov 3, 2022
79c63d1
Merge pull request #109 from quartiq/rj/path-errors
jordens Nov 3, 2022
64c5e36
Utilizing AtMostOnce for responses
ryan-summers Nov 3, 2022
4902507
Merge branch 'develop' into feature/minimq-update
ryan-summers Nov 3, 2022
560542e
Merge pull request #95 from quartiq/feature/minimq-update
ryan-summers Nov 3, 2022
2f8ee96
Updating client to use at-least-once responses
ryan-summers Nov 3, 2022
d920380
Updating changelog
ryan-summers Nov 3, 2022
dc984a2
Merge pull request #111 from quartiq/rs/qos-publish
jordens Nov 3, 2022
100ebcb
bump serde-json-core
jordens Nov 3, 2022
baaf020
use slice::fill()
jordens Nov 3, 2022
a9767f7
derive standard traits for Error
jordens Nov 3, 2022
51e38b9
Merge pull request #113 from quartiq/rj/fill_slice
jordens Nov 3, 2022
f8a362c
Bumping to ref master
ryan-summers Nov 4, 2022
de19a35
released serde-json-core, 0.6 release prep
jordens Nov 4, 2022
06022a4
Merge branch 'develop' into rj/bump-serde-json-core
ryan-summers Nov 4, 2022
672cf02
Merge pull request #112 from quartiq/rj/bump-serde-json-core
ryan-summers Nov 4, 2022
e92eb80
redesign docs
jordens Nov 4, 2022
6f3fb3a
update docs, readme, examples and doctests
jordens Nov 4, 2022
720d7b1
doc tweaks
jordens Nov 4, 2022
fd9c429
docs mention TrustedLen
jordens Nov 4, 2022
e862517
Merge pull request #114 from quartiq/rj/docs
ryan-summers Nov 4, 2022
0f743f5
v0.6.1 prep
jordens Nov 4, 2022
d63f68a
Merge pull request #115 from quartiq/rj/release-0.6.1
ryan-summers Nov 4, 2022
dd5beb0
reorganize derive macro
jordens Nov 4, 2022
fe5648c
refactor TypeDefinition
jordens Nov 5, 2022
fbfae43
allow zero arrays and empty structs
jordens Nov 5, 2022
318b121
array/option: derive common traits
jordens Nov 5, 2022
eedafff
unnecessary allow()s
jordens Nov 5, 2022
db9dd30
tweak default
jordens Nov 5, 2022
ff7272a
fix derive
jordens Nov 6, 2022
8fedb55
style
jordens Nov 6, 2022
2ac5705
add unreachable note
jordens Nov 6, 2022
30263ab
f->struct_field
jordens Nov 7, 2022
e176167
destructure once
jordens Nov 7, 2022
c06adf4
add quote context comments
jordens Nov 7, 2022
fac826c
update docs
jordens Nov 7, 2022
cdd0d83
Merge pull request #116 from quartiq/rj/derive-reorg
jordens Nov 7, 2022
601f942
rename derive_miniconf -> miniconf_derive, update categories, and rel…
jordens Nov 9, 2022
2b02fb1
this can remain a minor update
jordens Nov 9, 2022
ef5b1e1
style
jordens Nov 9, 2022
a449acc
Merge pull request #118 from quartiq/rj/rename-derive-release
jordens Nov 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,22 @@ jobs:
command: fmt
args: --all -- --check

- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/setup-python@v1
- name: Install Pylint
run: |
python -m pip install --upgrade pip
python -m pip install pylint

- name: Run Pylint
working-directory: py/miniconf-mqtt
run: |
python -m pip install .
python -m pylint miniconf


clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: thumbv7em-none-eabihf
override: true
components: clippy

- name: Clippy Check
uses: actions-rs/cargo@v1
with:
command: clippy

documentation:
runs-on: ubuntu-latest
steps:
Expand Down
65 changes: 62 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,70 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.6.2](https://github.com/quartiq/miniconf/compare/v0.6.1...v0.6.2) - 2022-11-09

* Renaming and reorganization of the the derive macro

## [0.6.1](https://github.com/quartiq/miniconf/compare/v0.6.0...v0.6.1) - 2022-11-04

* Documentation updates.

## [0.6.0](https://github.com/quartiq/miniconf/compare/v0.5.0...v0.6.0) - 2022-11-04

### Changed
* python module: don't emite whitespace in JSON to match serde-json-core (#92)
* `heapless::String` now implements `Miniconf` directly.
* Python client API is no longer retain by default. CLI is unchanged
* [breaking] Support for `#[derive(MiniconfAtomic)]` was removed.
* Fields in `#[derive(Miniconf)]` are now atomic by default. To recurse, users must
annotate fields with `#[miniconf(defer)]`
* New `miniconf::Option` type has been added. Existing `Option` implementation has been changed to
allow run-time nullability of values for more flexibility.
* New `miniconf::Array` type has been added, replacing the previous [T; N] implementation
* `Miniconf` implementation on most primitive types has been removed as it is no longer required.
* [breaking] The API has changed to be agnostic to usage (e.g. now referring to namespace paths and values
instead of topics and settings). Functions in the `Miniconf` trait have been renamed.
* [breaking] Errors and the Metadata struct have beem marked `#[non_exhaustive]`
* [breaking] `metadata()`, `unchecked_iter_paths()`, `iter_paths()`, `next_path()` are
all associated functions now.
* [breaking] Path iteration has been changed to move ownership of the iteration state into the iterator.
And the path depth is now a const generic.
* [breaking] Path iteration will always return all paths regardless of potential runtime `miniconf::Option`
or deferred `Option` being `None`.
* [breaking] `unchecked_iter_paths()` takes an optional iterator size to be used in `Iterator::size_hint()`.
* MQTT client now publishes responses with a quality of service of at-least-once to ensure
transmission.
* MQTT client no longer uses correlation data to ignore local transmissions.

### Fixed
* Python device discovery now only discovers unique device identifiers. See [#97](https://github.com/quartiq/miniconf/issues/97)
* Python requests API updated to use a static response topic
* Python requests now have a timeout
* Generic trait bound requirements have been made more specific.


## [0.5.0] - 2022-05-12

### Changed
* **breaking** The Miniconf trait for iteration was renamed from `unchecked_iter()` and `iter()` to
`unchecked_iter_settings()` and `iter_settings()` respectively to avoid issues with slice iteration
name conflicts. See [#87](https://github.com/quartiq/miniconf/issues/87)

## [0.4.0] - 2022-05-11

### Added
* Added support for custom handling of settings updates.
* `Option` support added to enable run-time settings tree presence.

### Changed
* [breaking] MqttClient constructor now accepts initial settings values.
* Settings republish will no longer register as incoming configuration requests. See
[#71](https://github.com/quartiq/miniconf/issues/71)
* [breaking] `into_iter()` and `unchecked_into_iter()` renamed to `iter()` and `unchecked_iter()`
respectively to conform with standard conventions.

### Removed
* The client no longer resets the republish timeout when receiving messages.

## [0.3.0] - 2021-12-13

Expand All @@ -24,7 +83,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* `miniconf::update()` replaced with `Miniconf::set()`, which is part of the trait and now
directly available on structures.


## [0.2.0] - 2021-10-28

### Added
Expand All @@ -38,7 +96,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Library initially released on crates.io

[Unreleased]: https://github.com/quartiq/miniconf/compare/v0.3.0...HEAD
[0.5.0]: https://github.com/quartiq/miniconf/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/quartiq/miniconf/compare/v0.3.0...v0.4.0
[0.3.0]: https://github.com/quartiq/miniconf/releases/tag/v0.3.0
[0.2.0]: https://github.com/quartiq/miniconf/releases/tag/v0.2.0
[0.1.0]: https://github.com/quartiq/miniconf/releases/tag/v0.1.0
21 changes: 12 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
[package]
name = "miniconf"
version = "0.3.0"
authors = ["James Irwin <irwineffect@gmail.com>", "Ryan Summers <ryan.summers@vertigo-designs.com"]

# Don't forget to change `miniconf_derive`'s version as well.
version = "0.6.2"

authors = ["James Irwin <irwineffect@gmail.com>", "Ryan Summers <ryan.summers@vertigo-designs.com", "Robert Jördens <rj@quartiq.de>"]
edition = "2018"
license = "MIT"
description = "Lightweight support for run-time settings configuration"
description = "Inspect serde namespaces by path"
repository = "https://github.com/quartiq/miniconf"
keywords = ["settings", "embedded", "no_std", "configuration", "mqtt"]
categories = ["no-std", "config", "embedded", "parsing"]
keywords = ["settings", "serde", "no_std", "json", "mqtt"]
categories = ["no-std", "config", "rust-patterns", "parsing"]

[dependencies]
derive_miniconf = { path = "derive_miniconf" , version = "0.3" }
serde-json-core = "0.4.0"
miniconf_derive = { path = "miniconf_derive" , version = "0.6" }
serde-json-core = "0.5.0"
serde = { version = "1.0.120", features = ["derive"], default-features = false }
log = "0.4"
heapless = { version = "0.7", features = ["serde"] }
minimq = { version = "^0.5.1", optional = true }
smlang = { version = "0.4", optional = true }
minimq = { version = "^0.6.1", optional = true }
smlang = { version = "0.6", optional = true }

[features]
default = ["mqtt-client"]
Expand Down
169 changes: 129 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,149 @@
# MiniConf

# Miniconf
[![crates.io](https://img.shields.io/crates/v/miniconf.svg)](https://crates.io/crates/miniconf)
[![docs](https://docs.rs/miniconf/badge.svg)](https://docs.rs/miniconf)
[![QUARTIQ Matrix Chat](https://img.shields.io/matrix/quartiq:matrix.org)](https://matrix.to/#/#quartiq:matrix.org)
![Continuous Integration](https://github.com/vertigo-designs/miniconf/workflows/Continuous%20Integration/badge.svg)

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](https://github.com/quartiq/minimq) as the MQTT client.
[![Continuous Integration](https://github.com/vertigo-designs/miniconf/workflows/Continuous%20Integration/badge.svg)](https://github.com/quartiq/miniconf/actions)

# Design
Miniconf enables lightweight (`no_std`) partial serialization (retrieval) and deserialization
(updates, modification) within a hierarchical namespace by path. The namespace is backed by
structs and arrays of serializable types.

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 can be used as a very simple and flexible backend for run-time settings management in embedded devices
over any transport. It was originally designed to work with JSON ([serde_json_core](https://docs.rs/serde-json-core))
payloads over MQTT ([minimq](https://docs.rs/minimq)) and provides a comlete [MQTT settings management
client](MqttClient) and a Python reference implementation to ineract with it.

MiniConf provides a `Miniconf` derive macro for creating a settings structure, e.g.:
## Example
```rust
use miniconf::Miniconf;
use serde::{Serialize, Deserialize};

#[derive(Miniconf)]
struct NestedSettings {
inner: f32,
#[derive(Deserialize, Serialize, Copy, Clone, Default)]
enum Either {
#[default]
Bad,
Good,
}

#[derive(Miniconf)]
struct MySettings {
initial_value: u32,
internal: NestedSettings,
#[derive(Deserialize, Serialize, Copy, Clone, Default, Miniconf)]
struct Inner {
a: i32,
b: i32,
}
```

# Settings Paths
#[derive(Miniconf, Default)]
struct Settings {
// Atomic updtes by field name
foo: bool,
enum_: Either,
struct_: Inner,
array: [i32; 2],
option: Option<i32>,

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:
```rust
#[derive(Miniconf)]
struct Data {
inner: f32,
// Exposing elements of containers
// ... by field name
#[miniconf(defer)]
struct_defer: Inner,
// ... or by index
#[miniconf(defer)]
array_defer: [i32; 2],
// ... or deferring to two levels (index and then inner field name)
#[miniconf(defer)]
array_miniconf: miniconf::Array<Inner, 2>,

// Hiding paths by setting the Option to `None` at runtime
#[miniconf(defer)]
option_defer: Option<i32>,
// Hiding a path and deferring to the inner
#[miniconf(defer)]
option_miniconf: miniconf::Option<Inner>
}

#[derive(Miniconf)]
struct Settings {
initial_value: u32,
internal: Data,
let mut settings = Settings::default();
let mut buf = [0; 64];

// Atomic updates by field name
settings.set("foo", b"true")?;
assert_eq!(settings.foo, true);

settings.set("enum_", br#""Good""#)?;
settings.set("struct_", br#"{"a": 3, "b": 3}"#)?;
settings.set("array", b"[6, 6]")?;
settings.set("option", b"12")?;
settings.set("option", b"null")?;

// Deep access by field name in a struct
settings.set("struct_defer/a", b"4")?;
// ... or by index in an array
settings.set("array_defer/0", b"7")?;
// ... or by index and then struct field name
settings.set("array_miniconf/1/b", b"11")?;

// If a deferred Option is `None` it is hidden at runtime
settings.set("option_defer", b"13").unwrap_err();
settings.option_defer = Some(0);
settings.set("option_defer", b"13")?;
settings.set("option_miniconf/a", b"14").unwrap_err();
*settings.option_miniconf = Some(Inner::default());
settings.set("option_miniconf/a", b"14")?;

// Serializing an element by path
let len = settings.get("foo", &mut buf)?;
assert_eq!(&buf[..len], b"true");

// Iterating over all elements
for path in Settings::iter_paths::<3, 32>().unwrap() {
let len = settings.get(&path, &mut buf)?;
if path.as_str() == "option_miniconf/a" {
assert_eq!(&buf[..len], b"14");
}
}

# Ok::<(), miniconf::Error>(())
```

## MQTT
There is an [MQTT-based client](MqttClient) that implements settings management over the [MQTT
protocol](https://mqtt.org) with JSON payloads. A Python reference library is provided that
interfaces with it.

```sh
# Discover the complete unique prefix of an application listening to messages
# under the topic `quartiq/application/12345` and set its `foo` setting to `true`.
python -m miniconf -d quartiq/application/+ foo=true
```

We can access `Data::inner` with the path `internal/inner`.
## Design
For structs with named fields, Miniconf offers a [derive macro](derive.Miniconf.html) to automatically
assign a unique path to each item in the namespace of the struct.
The macro implements the [Miniconf] trait that exposes access to serialized field values through their path.
All types supported by [serde_json_core] can be used as fields.

Elements of homogeneous [core::array]s are similarly accessed through their numeric indices.
Structs, arrays, and Options can then be cascaded to construct a multi-level namespace.
Namespace depth and access to individual elements instead of the atomic updates
is configured at compile (derive) time using the `#[miniconf(defer)]` attribute.
`Option` is used with `#[miniconf(defer)]` to support paths that may be absent (masked) at
runtime.

While the [Miniconf] implementations for [core::array] and [core::option::Option] by provide
atomic access to their respective inner element(s), [Array] and
[Option] have alternative [Miniconf] implementations that expose deep access
into the inner element(s) through their respective inner [Miniconf] implementations.

## Formats
The path hierarchy separator is the slash `/`.

Values are serialized into and deserialized from JSON.

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.
## Transport
Miniconf is designed to be protocol-agnostic. Any means that can receive key-value input from
some external source can be used to modify values by path.

# Settings Values
## Limitations
Deferred (non-atomic) access to inner elements of some types is not yet supported. This includes:
* Complex enums (other than [core::option::Option])
* Tuple structs (other than [Option], [Array])

MiniConf relies on using [`serde`](https://github.com/serde-rs/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.
## Features
* `mqtt-client` Enabled the MQTT client feature. See the example in [MqttClient].
19 changes: 0 additions & 19 deletions derive_miniconf/Cargo.toml

This file was deleted.

Loading