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, jigs, Request, Response};
#[derive(Clone, Request)]
struct Msg(String);
#[derive(Clone, Response)]
struct Out(Result<String, String>);
#[jig]
fn validate(r: Msg) -> Msg { r }
#[jig]
fn handle(r: Msg) -> Out {
Out::ok(format!("got {}", r.0))
}
let response = Msg("42".into()).then(validate).then(handle);
assert_eq!(response.0.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§
- json
- JSON string escaping utility shared by rendering crates.
- meta
- Compile-time metadata for every
#[jig]function in the binary.
Macros§
- fork
- Multi-arm fork. Predicates are checked in order; the first match
consumes the request and its jig is run. If none match, the
_ => defaultarm runs. Every arm must produce the sameOuttype; each arm’s internal pipeline can have its own intermediate types. - impl_
request - Wire a custom request type into the framework.
- impl_
response - Wire a custom response type into the framework.
- jigs
Structs§
- Chain
Step - One entry in a jig’s chain: the called jig’s name plus how it was composed with the surrounding pipeline.
- JigMeta
- Static description of one jig.
- Pending
- Wraps a future returned by an async jig so the chain remains spelled with
.then.
Enums§
- Branch
- Outcome of a guard jig: either continue with a (possibly transformed) request, or short-circuit the pipeline with a response.
- Chain
Kind - How a chain entry was reached from the surrounding jig.
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(...). - JigDef
- Trait implemented by the zero-sized marker struct that the
#[jig]macro emits alongside each jig function. The marker struct is named__Jig_<fn_name>to avoid namespace collisions with the function itself. Thejigs!macro calls<Entry as JigDef>::collectto recursively gather metadata for every reachable jig, with no link-time registration. - Merge
- Glue trait that lets a
Branch::then(jig)accept a jig whose output is a request, a response, or anotherBranch, and merge the two outcomes into a single value. - Request
- An inbound message flowing through a pipeline.
- Response
- An outbound message produced by a pipeline.
- 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.