#coap #iot #no-alloc

no-std coap-handler-implementations

Simple implementations of CoAP handlers

24 releases

new 0.6.0-alpha.1 Nov 2, 2024
0.5.1 Aug 29, 2024
0.5.0 Jan 16, 2024
0.4.2 Mar 6, 2023
0.1.0 Mar 23, 2021

#482 in No standard library

Download history 220/week @ 2024-07-17 42/week @ 2024-07-24 302/week @ 2024-07-31 174/week @ 2024-08-07 890/week @ 2024-08-14 1552/week @ 2024-08-21 970/week @ 2024-08-28 681/week @ 2024-09-04 1100/week @ 2024-09-11 545/week @ 2024-09-18 342/week @ 2024-09-25 391/week @ 2024-10-02 446/week @ 2024-10-09 529/week @ 2024-10-16 611/week @ 2024-10-23 737/week @ 2024-10-30

2,393 downloads per month
Used in 4 crates

MIT/Apache

110KB
2K SLoC

coap-handler-implementations License: MIT OR Apache-2.0 coap-handler-implementations on crates.io coap-handler-implementations on docs.rs Source Code Repository Rust Version: 1.79.0

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 TypeHandler 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.

Dependencies

~1.7–2.4MB
~52K SLoC