observer-rust-lib
Minimal Rust-facing provider micro-library for Observer.
If you are new to this surface, start with HOWTO.md before reading the individual snippets and starters.
This wraps the existing low-level Rust provider crates with the same human-first DX shape already used in C and TypeScript:
- authors write
describe!(...),test!(...),it!(...), andexpect(...) - default identity is derived deterministically from explicit suite path plus test title
- optional
id = ...provides a refactor-stable override when needed - observation is bounded and opt-in through
ctx.observe().* - direct host and embedded
observedispatch are owned by the library
The common path stays human-first. The deterministic boundary stays explicit.
Files
HOWTO.md: detailed user manual covering authoring, determinism, host transport, inventory derivation, and end-to-end workflowsrc/lib.rs: public APIexamples/example_smoke.rs: tiny collection and execution exampleexamples/host_example.rs: tiny directlistandrunhost exampleexamples/host_embed_example.rs: own-main styleobservenamespace examplestarter/: runnable project-shaped example with Cargo build, provider host build, inventory derivation, suite run, and snapshot verificationstarter-embedded/: runnable app-shaped example where the application keepsmain()and routesobserve ...through its own CLIstarter-embedded-failure/: runnable failing companion for the embedded app-shaped pathstarter-failure/: runnable failing companion showing the same provider flow with one intentionally failing exported test
If you want the full end-to-end workflow rather than isolated snippets, start with starter/, then read starter-embedded/, and then compare those with starter-failure/ and starter-embedded-failure/.
Minimal Shape
use ;
let tests = collect_tests?;
When id is omitted, Observer derives a deterministic identity from suite path, test title, and duplicate occurrence order.
If a test wants a refactor-stable identity, it opts into id explicitly:
test!;
If a test wants to emit observational data, it uses the author context directly:
test!;
Validation Rules
- explicit
id, when present, must be non-empty - resolved canonical identities must be unique
- resolved targets must be unique
- deterministic sorting is by canonical name, then target
In this first cut, the resolved identity is used for both canonical name and target.
Test
Smoke Example
Host Example
The library owns the standard provider host transport for Rust too. A direct host can stay nearly trivial:
use ;
For developer-facing usage, prefer observe. run remains available for compatibility with the standardized outer provider contract.
Own Main Integration
If a project already owns its CLI, the library can also serve an embedded observe namespace:
use ;
Compile and run that path with: