Skip to main content

Crate jigs_core

Crate jigs_core 

Source
Expand description

Core types for the jigs framework.

A jig is one step in a request-to-response pipeline. Four kinds exist:

  • Request to Request — enrich, validate, transform
  • Request to Response — handler that produces a response
  • Response to Response — post-process the outgoing message
  • Request to Branch<Req, Resp> — guard that may short-circuit

Pipelines are built by chaining jigs with .then(...). The type system enforces ordering: once you hold a Response, you cannot chain a jig that expects a Request. Branch::Done and errored request-handling jigs short-circuit the request side of the pipeline, but once a Response exists every Response -> Response jig runs — including on errored responses — so finalizers (logging, headers, error envelopes) always see the outcome. Jigs that should only act on success must check Response::is_ok themselves.

Re-exports§

pub use meta::all as all_jigs;
pub use meta::find as find_jig;
pub use meta::JigMeta;

Modules§

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

Structs§

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.