soothfast-registry API reference#
Generated by
cargo soothfast docs referenceMeasurements and verified claims come from the latest baseline; CI gates them.
soothfast_registry#
Assertions struct#
pub struct Assertions { pub max_allocs: Option<u64>, pub p99_ns: Option<u64>, pub complexity: Option<&'static str> }
Checked performance claims attached to a measured item. Evaluated by the runner after measurement; violations fail CI.
Bencher struct#
pub struct Bencher<'a> { }
Single-use measurement context handed to registered runner glue.
Generated glue performs setup, then calls [Bencher::iter] (or
[Bencher::iter_async]) exactly once with the workload; the active
backend decides how many times (and how) the workload body actually runs.
FixtureItem struct#
pub struct FixtureItem { pub id: &'static str, pub fingerprint: u64 }
A deterministic input-builder registered via #[soothfast::fixture].
MOCKS static#
#[linkme::distributed_slice]
All mock seams registered with #[soothfast::mock_seam].
MeasuredItem struct#
pub struct MeasuredItem { pub pkg: &'static str, pub module_path: &'static str, pub name: &'static str, pub group: &'static str, pub fingerprint: u64, pub covers: &'static str, pub setup: Option<&'static str>, pub runner: fn(&mut Bencher), pub assertions: Assertions, pub sizes: &'static [usize], pub sized_runner: Option<fn(&mut Bencher, usize)>, pub is_async: bool, pub tolerance_pct: Option<f64> }
A benchmarked item registered via #[soothfast::measured] or #[soothfast::bench].
MockSeam trait#
pub trait MockSeam: Send
A mocked backend a capture-output/test example can stand up by name.
Implemented by a thin consumer-side newtype around whatever mocking
crate they bring (mockito, wiremock, a hand-rolled stub server, ...).
Teardown is ordinary Drop on the concrete type — no separate teardown
method is needed.
MockSeamItem struct#
pub struct MockSeamItem { pub id: &'static str, pub fingerprint: u64, pub setup: fn(&str) -> Box<dyn MockSeam> }
A mock-backend setup fn registered via #[soothfast::mock_seam].
RouteItem struct#
pub struct RouteItem { pub id: &'static str, pub spec: &'static str, pub operation: &'static str, pub method: &'static str, pub path: &'static str, pub request: Option<&'static str>, pub response: Option<&'static str>, pub status: Option<u16>, pub params: Option<&'static str>, pub path_params: Option<&'static str>, pub summary: Option<&'static str> }
A declared route/operation registered via #[soothfast::route] — the
code-side half of spec reconciliation (cargo soothfast spec check).
async_counters function#
pub fn async_counters() -> (u64, u64)
(polls, wakes) since process start — backends diff snapshots around a body.
block_on_counting function#
pub fn block_on_counting<F: Future>(fut: F) -> F::Output
Minimal std-only executor with poll/wake counting: enough to measure how a future behaves (polls to completion, wake traffic) deterministically. No spawns, no timers — a tokio-instrumented backend is future work.
fixture_items function#
pub fn fixture_items() -> &'static [FixtureItem]
Read-only view of every registered fixture.
fnv1a function#
pub const fn fnv1a(bytes: &[u8]) -> u64
FNV-1a 64-bit hash.
STABILITY CONTRACT: fingerprints are compared across builds and stored in lockfiles, so this algorithm is frozen. Do not change constants or logic.
measured_items function#
pub fn measured_items() -> &'static [MeasuredItem]
Read-only view of every registered measured item.
mock_seam_items function#
pub fn mock_seam_items() -> &'static [MockSeamItem]
Read-only view of every registered mock seam.
resolve_mock_seam function#
pub fn resolve_mock_seam<'a>( items: &'a [MockSeamItem], name: &str, ) -> Result<&'a MockSeamItem, String>
Resolve a mock seam by name: an exact id match wins; otherwise exactly
one ::name suffix match. Pure/testable without linking real
#[mock_seam]-registered items — soothfast::mock::activate calls this
against the live MOCKS slice and panics with the returned message.
route_items function#
pub fn route_items() -> &'static [RouteItem]
Read-only view of every registered route.
soothfast_registry::Bencher#
iter function#
pub fn iter<T>(&mut self, mut f: impl FnMut() -> T)
Hand the workload to the active backend. Call exactly once per glue call.
iter_async function#
pub fn iter_async<F, Fut>(&mut self, mut f: F) where F: FnMut() -> Fut, Fut: Future,
Async workloads: each iteration drives the future to completion on the
counting executor (polls/wakes feed the asyncexec backend).
soothfast_registry::MeasuredItem#
full_id function#
pub fn full_id(&self) -> String
Package-qualified stable ID; survives file moves. In a lib target
module_path!() starts with the crate name and the ID reads naturally
(demo::lcg_checksum). In bench/test targets the first segment is the
target name (every crate's bench file is soothfast), which would
collide across packages and clobber shared baselines — substitute the
package name for it.
soothfast_registry::RouteItem#
new function#
pub const fn new( id: &'static str, spec: &'static str, operation: &'static str, method: &'static str, path: &'static str, ) -> Self
Const constructor for macro expansions.
with_shape function#
pub const fn with_shape( mut self, request: Option<&'static str>, response: Option<&'static str>, status: Option<u16>, ) -> Self
Attach the shape overrides. Separate from [RouteItem::new] so that
later spec dialects can add their own without growing its arity.