Myrmic SDK
The Myrmic SDK is the Rust library for writing cells.
Each page covers one topic: what it is for, the operations it offers, an example, and how it behaves. Use it when you know what you want to do and need the exact operations, behavior, or limits.
Cell model
- Cell initialization - Prepare a cell before it starts handling messages.
- Cell identity and metadata - Address a cell by its identity, and read the metadata of each handler invocation.
Messaging
- Commands - Receive and send directed, named messages between cells.
- Callbacks - Name a handler to receive the answer to a command.
- Events - Publish named messages and receive them through event handlers.
- Message encoding - Encode typed payloads, raw bytes, empty messages, and custom wire formats.
Scheduling and time
- Delayed handler invocations - Schedule a command handler to run once after a delay and cancel it when required.
- Periodic handler invocations - Invoke a command handler on a recurring period, optionally after an initial delay.
- Clock, uptime, and pausing - Read the current time, read how long a node has been running, and pause a handler.
Cell lifecycle
- Cell classes and spawning - Declare child classes and create supervised or detached cells at runtime.
- Cell termination - Terminate another cell or deliberately stop the current cell.
- Cell monitoring - Receive structured notifications when a supervised child cell is lost.
State and storage
- Storage scopes - Scope every operation on the runtime database, private to one cell or public and shared.
- Transient state - Hold a value in the cell's WebAssembly memory for as long as the cell runs.
- Persistent cell state - Store, load, mutate, and upsert one typed value that lives in the persistent runtime database.
- Key-value store - Store many typed values beneath a shared prefix, and read them by prefix.
- Table store - Keep a named collection of values of one type, each under a key, and read them in key order.
- Time-series store - Append timestamped measurements and query samples by series, range, limit, and order.
- Semantic store - Run SPARQL update and select queries over RDF triples.
- Blob store - Store, read, list, rename, and delete binary content held under file-like paths.
External systems
- Gateway routes - Expose a swarm to HTTP clients under a URL path, over plain HTTP or a WebSocket.
- Gateway assets - Serve static files from a cell's blob storage on a gateway route.
- Bridges - Connect a cell to an MQTT broker or an HTTP service outside the swarm.
Signal Layer (I/O)
- Signal taps - Read a Signal Layer input by name, either its latest value or its queued events.
- Signal outlets - Drive a device through a named Signal Layer output, writing a typed value or raw bytes.
Bluetooth Low Energy
- BLE scanning and discovery - Scan for peripherals, filter advertisements, and stop an active scan.
- BLE connections and service discovery - Establish a peripheral connection, inspect discovered services, and disconnect explicitly.
- BLE characteristic reads and writes - Read and write GATT characteristics through a host-managed connection.
- BLE notifications and subscriptions - Subscribe to GATT notifications, receive payloads through callbacks, and unsubscribe.
- BLE pairing - Secure a link with a passkey when a peripheral requires it.
Hardware
- GPIO - Acquire numbered pins, perform digital I/O, and wait for levels or edges.