Skip to main content

Crate jigs

Crate jigs 

Source
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 in jigs_trace (data) and jigs_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§

inventory
githubcrates-iodocs-rs
meta
Compile-time metadata for every #[jig] function in the binary.

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 Result so 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) -> Out automatically 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 a Request, a Response, or another Branch, 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, or Branch.
Step
Lifts the output of a jig into a future, so async and sync jigs can be chained uniformly inside a Pending chain. Sync values become a Ready future, a nested Pending is 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.

Attribute Macros§

jig