Skip to content
Merged

trace #280

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* py: a synchronous client version in `miniconf.sync`
* py: support for response-less (fire and forget) requests in both the synchronous and the asyncio client
* py: cli support for simple relative paths
* examples/trace: Tracing reflection with serde-reflection

### Changed

* py: `await discover_one(...)` -> `one(await discover(...))`
* serialize_by_key: returns serializer Ok instead of depth
* deserialize_by_key: returns () instead of depth
* TreeDeserialize: add probe_by_key() for tracing without sample
* Walk::internal() takes slice of children by value
* derive: deserialize validate doesn't receive or return depth

## [0.18.0](https://github.com/quartiq/miniconf/compare/v0.17.2...v0.18.0) - 2024-11-22

Expand Down
11 changes: 9 additions & 2 deletions miniconf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ embedded-io-adapters = { version = "0.6.1", features = ["tokio-1"] }
heapless = "0.8.0"
yafnv = "3.0.0"
tokio = { version = "1.38.0", features = ["io-std", "rt", "macros"] }
strum = { version = "0.26.3", features = ["derive"] }
strum = { version = "0.27.1", features = ["derive"] }
trybuild = { version = "1.0.99", features = ["diff"] }
serde_json = { version = "1.0.133" }
serde_json = "1.0.133"
serde-reflection = { version = "0.5", git = "https://github.com/quartiq/serde-reflection.git", branch = "pub-ser-de" }
indexmap = { version = "2.9", features = ["serde"] }
once_cell = "1.21.3"

[[test]]
name = "arrays"
Expand Down Expand Up @@ -110,3 +113,7 @@ required-features = ["json-core", "derive", "postcard"]
[[example]]
name = "scpi"
required-features = ["json-core", "derive"]

[[example]]
name = "trace"
required-features = ["json-core", "derive"]
6 changes: 2 additions & 4 deletions miniconf/examples/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ use anyhow::Context;
use miniconf::{json, Error, Path, Traversal, TreeKey};

mod common;
use common::Settings;

// Simple command line interface example for miniconf.
// This exposes all leaf nodes as long options, parses the command line,
// and then prints the settings struct as a list of option key-value pairs.

fn main() -> anyhow::Result<()> {
let mut settings = Settings::default();
settings.enable();
let mut settings = common::Settings::new();

// Parse args
let mut args = std::env::args().skip(1);
Expand All @@ -23,7 +21,7 @@ fn main() -> anyhow::Result<()> {

// Dump settings
let mut buf = vec![0; 1024];
for (key, _node) in Settings::nodes::<Path<String, '-'>, 4>().map(Result::unwrap) {
for (key, _node) in common::Settings::nodes::<Path<String, '-'>, 4>().map(Result::unwrap) {
match json::get_by_key(&settings, &key, &mut buf[..]) {
Ok(len) => {
println!(
Expand Down
7 changes: 7 additions & 0 deletions miniconf/examples/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ pub struct Settings {
}

impl Settings {
/// Create a new enabled Settings
pub fn new() -> Self {
let mut s = Self::default();
s.enable();
s
}

/// Fill some of the Options
pub fn enable(&mut self) {
self.option_tree = Some(8.into());
Expand Down
6 changes: 2 additions & 4 deletions miniconf/examples/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,7 @@ where
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<()> {
let mut buf = vec![0; 1024];
let mut s = common::Settings::default();
s.enable();
let mut s = common::Settings::new();

let mut stdout = embedded_io_adapters::tokio_1::FromTokio::new(tokio::io::stdout());
let mut stdin = tokio::io::BufReader::new(tokio::io::stdin()).lines();
Expand All @@ -301,8 +300,7 @@ mod test {
#[tokio::test]
async fn test() {
let mut buf = vec![0; 1024];
let mut s = common::Settings::default();
s.enable();
let mut s = common::Settings::new();

let mut stdout = embedded_io_adapters::tokio_1::FromTokio::new(tokio::io::stdout());
let mut menu = Menu::default();
Expand Down
4 changes: 1 addition & 3 deletions miniconf/examples/scpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use miniconf::{
};

mod common;
use common::Settings;

/// This show-cases the implementation of a custom [`miniconf::Key`]
/// along the lines of SCPI style hierarchies. It is case-insensitive and
Expand Down Expand Up @@ -134,8 +133,7 @@ impl<M: TreeSerialize + TreeDeserializeOwned> ScpiCtrl<M> {
}

fn main() -> anyhow::Result<()> {
let mut settings = Settings::default();
settings.enable();
let settings = common::Settings::new();
let mut ctrl = ScpiCtrl::new(settings);

ctrl.cmd("fO?; foo?; FOO?; :FOO?; :ARRAY_OPT:1:A?; A?; A?; A 1; A?; :FOO?")?;
Expand Down
Loading