22
33` miniconf_mqtt ` exposes a [ ` miniconf ` ] ( ../miniconf/README.md ) tree over MQTT using
44[ ` minimq ` ] ( ../../minimq/README.md ) .
5- It owns Miniconf MQTT protocol state; the caller owns both the MQTT session and the settings tree.
5+ It owns Miniconf MQTT protocol state; the caller owns the MQTT session, live connection, and
6+ settings tree.
67
78## Quick start
89
910See the runnable example in [ examples/miniconf.rs] ( examples/miniconf.rs ) .
1011
1112For simple services, ` miniconf_mqtt ` provides two complete unbounded helpers on top:
1213
13- - ` miniconf.startup(&mut session , &settings, connect_event ) `
14- - ` miniconf.serve(&mut session , &mut settings, on_unhandled) `
14+ - ` miniconf.startup(&mut connection , &settings) `
15+ - ` miniconf.serve(&mut connection , &mut settings, on_unhandled) `
1516
1617They are the easiest way to serve a Miniconf tree over MQTT when you do not need stepwise control,
1718bounded queued follow-up, or exact control over unrelated inbound traffic during protocol work.
@@ -28,9 +29,9 @@ For precise control, `miniconf_mqtt` exposes four explicit building blocks:
2829Typical flow:
2930
30311 . construct Miniconf MQTT state and session with ` Miniconf::new(prefix, config) `
31- 2 . call ` let event = session.connect(io).await? `
32- 3 . call ` miniconf.startup(&mut session , &settings, event ) `
33- 4 . in steady state, call ` miniconf.serve(&mut session , &mut settings, on_unhandled) `
32+ 2 . call ` let mut connection = session.connect(io).await? `
33+ 3 . call ` miniconf.startup(&mut connection , &settings) `
34+ 4 . in steady state, call ` miniconf.serve(&mut connection , &mut settings, on_unhandled) `
34355 . use ` Publisher::root(Settings::SCHEMA) ` or ` Publisher::by_key(Settings::SCHEMA, key) ` for explicit app-side retained
3536 republish
3637
@@ -40,10 +41,10 @@ Retained settings recovery is a cold-boot step:
4041
4142``` rust
4243let mut load = miniconf_mqtt :: LoadRetained :: new ();
43- load . run (& mut miniconf , & mut session , & mut settings ). await ? ;
44+ load . run (& mut miniconf , & mut connection , & mut settings ). await ? ;
4445
4546let mut startup = miniconf_mqtt :: Startup :: connected (& mut miniconf );
46- startup . run (& mut miniconf , & mut session , & settings ). await ? ;
47+ startup . run (& mut miniconf , & mut connection , & settings ). await ? ;
4748```
4849
4950` LoadRetained ` applies only retained ` settings/<leaf> ` publications with ` auth="" ` , waits for
@@ -53,7 +54,7 @@ retained pruning remains a client/tooling operation.
5354
5455Use it only before the first Miniconf MQTT startup of a device process. On a device reconnect or
5556network glitch, keep the live settings in RAM authoritative and call
56- ` miniconf.startup(..., connect_event) ` :
57+ ` miniconf.startup(...) ` ; it reads the connect event from the live connection :
5758
5859- ` ConnectEvent::Connected ` : the broker did not resume the MQTT session, so Miniconf republishes
5960 schema, settings, ` set/# ` , and ` alive `
@@ -103,8 +104,8 @@ Stepwise APIs:
103104
104105Practical boundary:
105106
106- - use ` Session ::poll()` to wait for any later session progress
107- - use ` Session ::recv()` when you specifically want the next inbound publish
107+ - use ` Connection ::poll()` to wait for any later session progress
108+ - use ` Connection ::recv()` when you specifically want the next inbound publish
108109- ` Startup::step() ` may consume and discard inbound publishes while bootstrapping
109110- ` Publisher::step() ` must not consume unrelated inbound publishes
110111- ` Service::step() ` must not consume unrelated inbound publishes
@@ -118,9 +119,9 @@ Bounded cooperative serving:
118119let mut service = Service :: <4 >:: new ();
119120
120121loop {
121- let _empty = service . step (& mut miniconf , & mut session , & settings ). await ? ;
122+ let _empty = service . step (& mut miniconf , & mut connection , & settings ). await ? ;
122123
123- if let Some (inbound ) = session . poll (). await ? {
124+ if let Some (inbound ) = connection . poll (). await ? {
124125 match service . handle (& mut miniconf , & mut settings , & inbound ) {
125126 ServiceEvent :: Unhandled => { /* app traffic */ }
126127 ServiceEvent :: Changed (_ ) | ServiceEvent :: Busy | ServiceEvent :: Idle => {}
0 commit comments