Expand description
§miniconf_coap
miniconf_coap exposes selected miniconf trees as
CoAP resources. It is sessionless: applications keep ownership of CoAP sockets,
message IDs, tokens, routing, retransmission, unrelated resources, and the
settings tree unless they opt into the coap-handler adapter.
§Routes
JsonValueRoute::json("/settings")serves leaf values as JSON.CborValueRoute::cbor("/settings")serves leaf values as CBOR when thecborfeature is enabled.SchemaRoute::new("/schema", Settings::SCHEMA)serves a JSON manifest at/schemaand newline-delimited compact schema pages at/schema/{page}.
The cooperative routes borrow settings for each request:
use miniconf::{Tree, TreeSchema};
use miniconf_coap::{JsonValueRoute, Outcome, RequestParts, SchemaRoute};
#[derive(Default, Tree)]
struct Settings {
enabled: bool,
}
let values = JsonValueRoute::json("/settings");
let schema = SchemaRoute::new("/schema", Settings::SCHEMA);
let mut settings = Settings::default();
let mut response = [0; 128];
let request = RequestParts::new(
coap_numbers::code::GET,
&["settings", "enabled"],
None,
None,
b"",
)
.unwrap();
match values.handle(&request, &mut settings, &mut response) {
Outcome::Handled(response) => assert_eq!(response.payload, b"false"),
_ => unreachable!(),
}
let request = RequestParts::new(coap_numbers::code::GET, &["schema"], None, None, b"").unwrap();
assert!(schema.handle(&request, &mut response).response().is_some());§coap-handler
With the coap-handler feature, MiniconfCoapHandler and SchemaCoapHandler
adapt the routes to the coap-handler ecosystem. MiniconfCoapHandler owns its
settings because coap-handler::Handler has no per-request application context;
use ValueRoute directly when other components need cooperative access to the
same settings tree.
§Features
json-core(default): JSON value routes and compact schema serving.cbor: CBOR value routes and concise problem details.coap-handler: adapters and CoRE Link Format discovery records.
Structs§
- Cbor
- URI path segments as Miniconf keys, with CBOR payloads.
- Error
- CoAP handler error.
- Json
- URI path segments as Miniconf keys, with JSON payloads.
- Miniconf
Coap Handler coap-handleradapter for Miniconf leaf value resources.- Request
Parts - Parsed CoAP request data used by cooperative handlers.
- Response
- CoAP response data produced by cooperative handlers.
- Schema
Coap Handler coap-handleradapter for a Miniconf JSON schema resource.- Schema
Route - Schema route backed by a Miniconf schema.
- Value
Route - Leaf value route backed by a Miniconf tree.
Enums§
- Operation
- CoAP operation being performed.
- Outcome
- Handler outcome.
- Problem
- Problem details preserved in error responses.
Constants§
- MAX_
DEPTH - Maximum Miniconf tree depth supported by
miniconf_coap. - MAX_
HANDLER_ RESPONSE_ LENGTH - Maximum value, schema, or error response bytes staged by the optional
coap-handleradapter. - MAX_
SCHEMA_ DEFS - Maximum compact schema definitions served by
miniconf_coap. - MAX_
URI_ PATH_ LENGTH - Maximum bytes in a captured rooted CoAP URI path.
Type Aliases§
- Cbor
Value Route - CBOR value route.
- Changed
Key - Exact changed leaf indices produced by a successful
PUT. - Json
Value Route - JSON value route.