Expand description
jigs — explicit, composable, traceable processing pipelines.
A jig is one step in a request-to-response pipeline. Steps are chained
with Request::then, Response::then and Branch::then, and the
type system enforces ordering: once a Response exists you cannot fall
back to chaining a Request-shaped step.
This crate is a thin facade. The runtime types live in jigs_core and
the jig attribute macro lives in jigs_macros. With the optional
trace feature, every #[jig] call site records its name, depth, outcome
and wall-clock duration into a per-thread buffer exposed under trace.
§Example
use jigs::{jig, Request, Response};
#[jig]
fn validate(r: Request<u32>) -> Request<u32> { r }
#[jig]
fn handle(r: Request<u32>) -> Response<String> {
Response::ok(format!("got {}", r.0))
}
let response = Request(42u32).then(validate).then(handle);
assert_eq!(response.inner.unwrap(), "got 42");§Features
trace— pulls injigs_trace(data) andjigs_log(renderers), and instruments every#[jig]call.
Re-exports§
pub use jigs_trace as trace;pub use jigs_log as log;pub use jigs_map as map;
Modules§
Structs§
- JigMeta
- Static description of one jig.
- Pending
- Wraps a future returned by an async jig so the chain remains spelled with
.then. - Request
- Inbound message flowing through a pipeline.
- Response
- Outbound message produced by a pipeline. Wraps a
Resultso that downstream jigs can short-circuit on error.
Enums§
- Branch
- Outcome of a guard jig: either continue with a (possibly transformed) request, or short-circuit the pipeline with a response.
Traits§
- Jig
- One step in a jigs pipeline. Any
Fn(In) -> Outautomatically implements this trait, so plain functions, closures, and#[jig]-annotated functions can all be chained with.then(...). - Merge
- Glue trait that lets a
Branch::then(jig)accept a jig whose output is aRequest, aResponse, or anotherBranch, and merge the two outcomes into a single value. - Status
- Common interface used by tracing to inspect a jig’s outcome without
knowing whether the value is a
Request,Response, orBranch. - Step
- Lifts the output of a jig into a future, so async and sync jigs can be chained
uniformly inside a
Pendingchain. Sync values become aReadyfuture, a nestedPendingis unwrapped to its inner future.
Functions§
- all_
jigs - Iterator over every jig registered in the current binary.
- find_
jig - Look up a jig by name.
O(N)over the registry.