csi-webserver-core
Embeddable Rust library for bridging ESP32 CSI firmware (esp-csi-cli-rs) to
HTTP and WebSocket clients. Use this crate when you want to run the CSI server
inside your own process, register devices programmatically, or build a custom
host application.
For the ready-to-run executable, see csi-webserver.
Documentation
- Rust API reference: https://docs.rs/csi-webserver-core
- HTTP route handlers and request types:
src/routes/,src/models.rs - This guide: embedding, supervisor, and registration
Features
- Axum HTTP API under
/api/devices/{id}/... - Per-device WebSocket CSI frame stream (
/ws) - Parquet session dumps (decoded from serialized COBS+postcard frames)
- USB hotplug supervisor (
supervisor) - Explicit device registration (
DeviceRegistry::attach)
Quick embed
[]
= "0.1.0"
= { = "1", = ["full"] }
= { = "0.3", = ["env-filter"] }
use Duration;
use ;
async
Register a device without hotplug
use ;
let state = new;
state.devices.attach;
Use supervisor::probe_port to read native_usb and MAC
from USB enumeration before attaching.
Public API surface
| Export | Purpose |
|---|---|
AppState, DeviceRegistry, DeviceHandle, DeviceAttachSpec |
Shared runtime state |
ServerConfig, build_router, serve |
HTTP server |
SupervisorConfig, run_supervisor, detect_esp_ports, probe_port |
Hotplug discovery |
models |
JSON request/response types and CLI command mappers |
csi |
COBS/postcard frame decoder |
routes |
Axum handler functions (for custom router extension) |
serial, parquet_sink |
Lower-level pipelines |
Custom router
Mount the default routes or compose your own:
use Router;
use ;
let state = new;
let app: Router = build_router;
// or nest `build_router(state)` under your own paths
Migration from pre-0.1.5 single crate
| Before | After |
|---|---|
csi_webserver::run_supervisor |
csi_webserver_core::run_supervisor |
spawn_device + registry.insert |
registry.attach(DeviceAttachSpec { ... }) |
| Binary in same crate | Use csi-webserver or embed this library |
Related crates
| Crate | Role |
|---|---|
csi-webserver-core |
This library |
csi-webserver |
Default executable + HTTP API |
License
Apache-2.0. See LICENSE.