async_inspect/
lib.rs

1//! # async-inspect 🔍
2//!
3//! > X-ray vision for async Rust
4//!
5//! **async-inspect** visualizes and inspects async state machines in Rust.
6//! See exactly what your futures are doing, where they're stuck, and why.
7//!
8//! ## Quick Start
9//!
10//! ```rust,ignore
11//! use async_inspect::prelude::*;
12//!
13//! #[async_inspect::trace]
14//! async fn fetch_user(id: u64) -> User {
15//!     let profile = fetch_profile(id).await;
16//!     let posts = fetch_posts(id).await;
17//!     User { profile, posts }
18//! }
19//! ```
20//!
21//! ## Features
22//!
23//! - 🔍 **State Machine Inspection** - See current state and variables
24//! - ⏱️ **Execution Timeline** - Visualize async execution
25//! - 💀 **Deadlock Detection** - Find circular dependencies
26//! - 📊 **Performance Analysis** - Identify bottlenecks
27
28#![warn(missing_docs)]
29#![warn(clippy::all)]
30#![warn(clippy::pedantic)]
31#![allow(clippy::module_name_repetitions)]
32
33/// Core inspection types and traits
34pub mod inspector {
35    //! Core inspection functionality
36}
37
38/// State machine introspection
39pub mod state_machine {
40    //! State machine analysis and visualization
41}
42
43/// Task tracking and monitoring
44pub mod task {
45    //! Task lifecycle tracking
46}
47
48/// Timeline and execution history
49pub mod timeline {
50    //! Execution timeline tracking
51}
52
53/// Deadlock detection
54pub mod deadlock {
55    //! Deadlock detection and analysis
56}
57
58/// Performance profiling
59pub mod profile {
60    //! Performance analysis tools
61}
62
63/// Runtime integration hooks
64pub mod runtime {
65    //! Integration with async runtimes
66    
67    #[cfg(feature = "tokio")]
68    pub mod tokio {
69        //! Tokio runtime integration
70    }
71}
72
73/// Instrumentation and tracing
74pub mod instrument {
75    //! Code instrumentation utilities
76}
77
78/// Error types
79pub mod error {
80    //! Error definitions
81    
82    use thiserror::Error;
83    
84    /// Main error type for async-inspect
85    #[derive(Error, Debug)]
86    pub enum Error {
87        /// Inspection error
88        #[error("Inspection error: {0}")]
89        Inspection(String),
90        
91        /// Runtime error
92        #[error("Runtime error: {0}")]
93        Runtime(String),
94        
95        /// Serialization error
96        #[error("Serialization error: {0}")]
97        Serialization(#[from] serde_json::Error),
98        
99        /// IO error
100        #[error("IO error: {0}")]
101        Io(#[from] std::io::Error),
102    }
103    
104    /// Result type alias
105    pub type Result<T> = std::result::Result<T, Error>;
106}
107
108/// Prelude for convenient imports
109pub mod prelude {
110    //! Convenient re-exports
111    //!
112    //! ```rust
113    //! use async_inspect::prelude::*;
114    //! ```
115    
116    pub use crate::inspector::*;
117    pub use crate::state_machine::*;
118    pub use crate::task::*;
119    pub use crate::error::{Error, Result};
120}
121
122// Re-exports
123pub use error::{Error, Result};
124
125#[cfg(test)]
126mod tests {
127    use super::*;
128
129    #[test]
130    fn test_placeholder() {
131        // Placeholder test
132        assert_eq!(2 + 2, 4);
133    }
134}