#coap #iot

coap-handler-implementations

Simple implementations of CoAP handlers

14 releases

Uses new Rust 2021

0.3.5 Sep 22, 2022
0.3.4 Jun 10, 2022
0.3.3 Mar 14, 2022
0.1.5 Nov 15, 2021
0.1.0 Mar 23, 2021

#11 in #coap

Download history 65/week @ 2022-06-09 34/week @ 2022-06-16 65/week @ 2022-06-23 31/week @ 2022-06-30 40/week @ 2022-07-07 22/week @ 2022-07-14 47/week @ 2022-07-21 18/week @ 2022-07-28 24/week @ 2022-08-04 14/week @ 2022-08-11 27/week @ 2022-08-18 23/week @ 2022-08-25 52/week @ 2022-09-01 146/week @ 2022-09-08 84/week @ 2022-09-15 310/week @ 2022-09-22

594 downloads per month
Used in coap-message-demos

MIT/Apache

79KB
1.5K SLoC

Build Status

coap-handler-implementations

The coap-handler-implementations crate provides a few convenience, example or reference implementations of the coap-handler interface.

They range from the generic "4.04 Not Found" responder up to a handler that creates a write formatter for GET-only resources, and even provides block-wise transfer that. The [SimpleWrapper] enables the easy creation of serde_cbor based resource implementations with GET, PUT and POST support in CBOR format. The HandlerBuilder implements crude static path based routing that may suffice for some applications, and is also useful to get started quickly.

History

This code used to be part of coap-handler, but while the interface needs to stabilize fast (as incompatible changes there propagate to implementations), the implementations still need to develop fast (but it doesn't hurt too much if one code part is using the old SimpleRenderable while another uses a newer NeverFound).

Version 0.1 is what was available in coap-handler (if Cargo allowed cyclic dependencies, coap-handler would pub use this crate); users are encouraged to just use coap-handler-implementations directly.

Options Hiding

A common mechanism in handlers is that handlers "consume" options. For example, the [ForkingHandler] built through [HandlerBuilder::at] "eats" the Uri-Path; likewise, an Accept-based dispatcher would consume the Accept option.

This allows the handlers themselves to check for any left-over critical options and fail if they can't handle them -- without the need to mask them out there assuming (without an actual check) that prior wrappers took care of them.

License: MIT OR Apache-2.0

Dependencies

~0.9–1.5MB
~33K SLoC