Bronze is a CoAP framework generally aimed at making high performance CoAP servers. It's not currently intended for use on especially resource constrained devices, but that is a long-term goal.
Bronze is written using mio for all network requests, this means that it has very low overheads
Bronze is incomplete and you likely shouldn't use it.
Currently it is possible to create servers that directly deal with incoming CoAP packets, but there is not yet any automatic handling of retries or multi-packet messages.
There is not yet any implementation of client requests.
To use Bronze, add the following to your Cargo.toml
:
toml
[dependencies]
bronze = "0.1"
Then you'll need to create a run the server, a simple example of this would be:
```rust extern crate bronze;
use bronze::endpoint::Endpoint; use bronze::nullserver::NullServer;
fn main() { let localaddr = "127.0.0.1:5683".parse().unwrap(); println!("CoAP Server Listening on {}", localaddr); Endpoint::new(local_addr).run(NullServer); } ```
This example uses the included NullServer
which is an example of how to write
a request handler. NullServer simply replies to all valid CoAP packets with RST
messages. It's implemented with:
```rust use message::*; use endpoint::RequestHandler;
use std::net::SocketAddr;
pub struct NullServer;
impl RequestHandler for NullServer {
fn handlerequest(&self, _addr: SocketAddr, inpkt: &[u8]) -> Option
Some(reply.as_bin().unwrap())
},
// not coap, ignore (prevents participating in reflection attacks)
Err(_) => {
None
}
}
}
}
```