apiari-common
Minimal shared library for the Apiari toolchain. Used by swarm (TUI agent multiplexer) and hive (orchestration daemon) to share IPC and state persistence primitives.
Modules
ipc — JSONL read/write with cursor-based polling
Generic reader and writer for line-delimited JSON files.
JsonlReader<T>— Tracks a byte offset so each call topoll()returns only newly appended records. Supportsskip_to_end()andwith_offset()for resuming from persisted cursors. Malformed lines are silently skipped.JsonlWriter<T>— Appends serialized records as JSON lines. Creates parent directories and the file automatically.
use ;
let writer = new;
writer.append?;
let mut reader = new;
let new_messages = reader.poll?;
state — Atomic JSON state persistence
Two functions for loading and saving arbitrary state to JSON files:
load_state<T>(path)— Reads and deserializes a JSON file. ReturnsT::default()if the file doesn't exist.save_state<T>(path, state)— Writes atomically (write to.tmp, then rename) so a crash mid-write never corrupts the on-disk file. Creates parent directories automatically.
use ;
let state: MyState = load_state?; // returns Default if missing
save_state?; // atomic write
Dependencies
Intentionally minimal — only serde and serde_json. This keeps compile times low and avoids pulling transitive dependencies into downstream crates.
Usage
[]
= true
License
MIT