1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! Robust, ergonomic CoAP server in Rust.
//!
//! # Examples
//! ```no_run
//! use std::net::SocketAddr;
//!
//! use coap_server::app::{CoapError, Request, Response};
//! use coap_server::{app, CoapServer, FatalServerError, UdpTransport};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), FatalServerError> {
//! let server = CoapServer::bind(UdpTransport::new("0.0.0.0:5683")).await?;
//! server.serve(
//! app::new().resource(
//! app::resource("/hello").get(handle_get_hello))
//! ).await
//! }
//!
//! async fn handle_get_hello(request: Request<SocketAddr>) -> Result<Response, CoapError> {
//! let whom = request
//! .unmatched_path
//! .first()
//! .cloned()
//! .unwrap_or_else(|| "world".to_string());
//!
//! let mut response = request.new_response();
//! response.message.payload = format!("Hello, {whom}").into_bytes();
//! Ok(response)
//! }
//! ```
//!
//! See other [examples](https://github.com/jasta/coap-server-rs/tree/main/examples) for more information.
extern crate core;
pub use CoapServer;
pub use FatalServerError;
pub use UdpTransport;