async_reify/lib.rs
1#![deny(unsafe_code)]
2
3//! # async-reify
4//!
5//! Instrument async functions to extract their continuation structure
6//! as an inspectable, serializable step graph.
7//!
8//! The core workflow:
9//! 1. Wrap futures in [`TracedFuture`] to record [`PollEvent`]s
10//! 2. Use [`LabeledFuture`] to attach source labels to await points
11//! 3. Extract an [`AsyncStepGraph`] from the collected trace
12//! 4. Optionally serialize to JSON or render as Graphviz DOT
13//!
14//! # Examples
15//!
16//! ```
17//! use async_reify::{TracedFuture, PollResult};
18//!
19//! # tokio_test::block_on(async {
20//! let (result, trace) = TracedFuture::run(async { 42 }).await;
21//! assert_eq!(result, 42);
22//! assert!(!trace.events.is_empty());
23//! assert!(matches!(trace.events.last().unwrap().result, PollResult::Ready));
24//! # });
25//! ```
26
27mod graph;
28mod labeled;
29mod traced;
30
31pub use graph::{reify_execution, to_dot, AsyncStepGraph, StepNode, StepOutcome};
32pub use labeled::LabeledFuture;
33pub use traced::{PollEvent, PollResult, Trace, TracedFuture};
34
35/// Attribute proc macro that rewrites every `.await` in an async function
36/// body into a [`LabeledFuture`] recording into a shared [`Trace`].
37///
38/// Re-exported from `async-reify-macros` when the `macros` feature is
39/// enabled.
40#[cfg(feature = "macros")]
41pub use async_reify_macros::trace_async;