allframe_core/lib.rs
1//! # AllFrame Core
2//!
3//! The composable Rust API framework.
4//!
5//! AllFrame is the first Rust web framework designed, built, and evolved
6//! exclusively through Test-Driven Development (TDD).
7//!
8//! ## Quick Start
9//!
10//! ```rust,no_run
11//! use allframe_core::prelude::*;
12//!
13//! #[tokio::main]
14//! async fn main() {
15//! println!("AllFrame - One frame. Infinite transformations.");
16//! }
17//! ```
18
19#![deny(warnings)]
20#![deny(missing_docs)]
21#![deny(unsafe_code)]
22
23/// Clean Architecture enforcement
24#[cfg(feature = "di")]
25pub mod arch;
26
27/// CQRS + Event Sourcing
28#[cfg(feature = "cqrs")]
29pub mod cqrs;
30
31/// OpenTelemetry automatic instrumentation
32#[cfg(feature = "otel")]
33pub mod otel;
34
35/// Router module for protocol-agnostic request handling
36pub mod router;
37
38/// Graceful shutdown utilities
39pub mod shutdown;
40
41// ============================================================================
42// Re-exported dependencies
43// ============================================================================
44// These re-exports allow consumers to use common dependencies without adding
45// them explicitly to their Cargo.toml. This ensures version consistency and
46// reduces boilerplate in downstream crates.
47
48/// Re-export async_graphql for GraphQL support
49#[cfg(feature = "router-graphql")]
50pub use async_graphql;
51/// Re-export async_graphql_parser for GraphQL parsing
52#[cfg(feature = "router-graphql")]
53pub use async_graphql_parser;
54/// Re-export async_trait for async trait definitions
55pub use async_trait;
56/// Re-export futures for async utilities
57#[cfg(feature = "router-grpc")]
58pub use futures;
59/// Re-export hyper for HTTP primitives
60pub use hyper;
61/// Re-export prost for protobuf support
62#[cfg(feature = "router-grpc")]
63pub use prost;
64/// Re-export prost_types for well-known protobuf types
65#[cfg(feature = "router-grpc")]
66pub use prost_types;
67/// Re-export serde for serialization
68pub use serde;
69/// Re-export serde_json for JSON handling
70pub use serde_json;
71/// Re-export tokio for async runtime
72pub use tokio;
73/// Re-export tokio_stream for async streams
74#[cfg(feature = "router-grpc")]
75pub use tokio_stream;
76/// Re-export tonic for gRPC support
77#[cfg(feature = "router-grpc")]
78pub use tonic;
79/// Re-export tonic_reflection for gRPC reflection
80#[cfg(feature = "router-grpc")]
81pub use tonic_reflection;
82
83/// Re-export tracing for observability
84#[cfg(feature = "otel")]
85pub use tracing;
86
87// ============================================================================
88// Re-exported macros
89// ============================================================================
90
91/// Re-export GrpcError derive macro for automatic tonic::Status conversion
92#[cfg(feature = "router-grpc")]
93pub use allframe_macros::GrpcError;
94
95/// Prelude module for convenient imports
96///
97/// Commonly used imports for AllFrame applications
98pub mod prelude {
99 pub use crate::router::{
100 GraphQLAdapter, GrpcAdapter, GrpcRequest, GrpcStatus, Method, ProtocolAdapter, RestAdapter,
101 RestRequest, RestResponse, RouteMetadata, Router, ToJsonSchema,
102 };
103 #[cfg(feature = "router")]
104 pub use crate::router::{GraphQLConfig, GrpcConfig, RestConfig, RouterConfig, ServerConfig};
105
106 /// Re-export shutdown utilities
107 pub use crate::shutdown::{GracefulShutdown, ShutdownSignal, ShutdownToken};
108
109 /// Re-export GrpcError for convenient error handling
110 #[cfg(feature = "router-grpc")]
111 pub use crate::GrpcError;
112}
113
114#[cfg(test)]
115mod tests {
116 #[test]
117 fn test_allframe_core_exists() {
118 // This test verifies the crate compiles
119 assert!(true);
120 }
121}