| Crates.io | clasp-embedded |
| lib.rs | clasp-embedded |
| version | 3.0.1 |
| created_at | 2026-01-17 00:43:24.769085+00 |
| updated_at | 2026-01-24 00:57:58.317995+00 |
| description | CLASP embedded/no_std implementation - uses standard v3 protocol |
| homepage | |
| repository | |
| max_upload_size | |
| id | 2049603 |
| size | 45,717 |
Minimal no_std implementation of the standard CLASP v3 protocol for embedded devices.
#![no_std]
use clasp_embedded::{Client, Value, HEADER_SIZE};
fn main() {
let mut client = Client::new();
// Prepare HELLO frame to send
let hello = client.prepare_hello("ESP32-Sensor");
// send(hello) via your transport...
// Prepare SET frame
let set = client.prepare_set("/sensor/temp", Value::Float(25.5));
// send(set)...
// Process received data
let received_bytes: &[u8] = /* from transport */;
if let Some(msg) = client.process(received_bytes) {
match msg {
Message::Set { address, value } => {
// Handle incoming SET
}
Message::Welcome { .. } => {
// Connected!
}
_ => {}
}
}
// Read cached values
if let Some(temp) = client.get_cached("/sensor/temp") {
// Use temp.as_float()
}
}
#![no_std]
use clasp_embedded::server::MiniRouter;
use clasp_embedded::Value;
fn main() {
let mut router = MiniRouter::new();
// Set local state
router.set("/light/brightness", Value::Float(0.8));
// Process client message, get optional response
let client_data: &[u8] = /* from transport */;
if let Some(response) = router.process(0, client_data) {
// send(response) back to client
}
// Read state
if let Some(v) = router.get("/light/brightness") {
// ...
}
}
| Component | Size |
|---|---|
Client |
~3KB |
MiniRouter |
~4KB |
| State cache (32 entries) | ~2KB |
ESP32: Uses <2% of available 320KB SRAM.
[dependencies]
clasp-embedded = { version = "0.1", features = ["client"] }
# Or for server mode:
clasp-embedded = { version = "0.1", features = ["server"] }
# Or both:
clasp-embedded = { version = "0.1", features = ["client", "server"] }
Messages are 100% compatible with the full CLASP router. An ESP32 running clasp-embedded can:
no_std Rust supportLicensed under either of Apache License, Version 2.0 or MIT license at your option.
Maintained by LumenCanvas