Skip to content

Rust in HCR

Rust from server replay to embedded robot firmware

HCR uses the Rust programming language where policy, replay, protocol state, and validated hardware control meet. The browser interface remains React and Blockly; Rust runs the service and embedded gateway.

Underneath

Two Rust runtimes, two deployment constraints

The scoring service uses the additive hcr.v1 contract and authoritative replay. The current no_std ESP8266 gateway runs a bounded HTTP/JSON servo API; MQTT and CBOR remain a planned device path.

Rust · MQTT over WebSocket · HTTP binding

Service

Replays programs server-side, runs the adaptive question bank, and owns round deadlines and standings.

hcr-backend

hcr.v1 · JSON and CBOR

Protocol

One envelope for every message, correlated by ULID. Minor versions are additive only; receivers drop what they do not recognise rather than failing.

hcr-backend/schema

Rust (no_std) · ESP8266 · Arduino C++ as a hardware library

Hardware

A physical five-servo arm. Rust owns startup policy, routing, HTTP/JSON and servo state; C++ is confined behind a byte-oriented C ABI. MQTT is not implemented in the gateway yet.

hcr-fw

Open source

The Hotaru Rust ecosystem behind HCR

HCR publishes its backend service crate on crates.io and builds its service and embedded protocol layers on Hotaru. Explore the crate, framework website, core repository, and separately maintained MQTT implementation.

Design

Rust owns the policy; C++ is a hardware library

The dependency runs in one direction. Only one crate declares imported hardware functions, and the boundary carries bytes rather than Arduino strings, C++ objects, routes, JSON, or application state.

Rust owns

  • Startup policy and the cooperative executor
  • Hotaru routing and the protocol
  • HTTP parsing and responses
  • Servo validation and state

C++ owns

  • Clocks, interrupt masking, watchdog, restart, heap, random, serial
  • Wi-Fi access-point and station modes, raw TCP and UDP handles
  • Captive DNS and SPIFFS handles
  • GPIO, PWM, servo pulse writes, raw OTA writes

Rust

What Rust means in HCR

Rust is used where HCR needs deterministic replay, explicit protocol types, controlled concurrency, and a narrow embedded boundary. It is a concrete architecture choice, not a claim that every part of HCR is written in Rust.

The browser UI is built with React and TypeScript. HCR is an independent project and is not affiliated with or endorsed by the Rust Project or the Rust Foundation.

Hardware