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/// Cache abstraction
36pub mod cache;
37
38/// Dependency injection infrastructure
39#[cfg(feature = "di")]
40pub mod di;
41
42/// Health check infrastructure
43pub mod health;
44
45/// Router module for protocol-agnostic request handling
46pub mod router;
47
48/// Graceful shutdown utilities
49pub mod shutdown;
50
51/// gRPC server infrastructure
52#[cfg(feature = "router-grpc")]
53pub mod grpc;
54
55// ============================================================================
56// Re-exported dependencies
57// ============================================================================
58// These re-exports allow consumers to use common dependencies without adding
59// them explicitly to their Cargo.toml. This ensures version consistency and
60// reduces boilerplate in downstream crates.
61
62// ============================================================================
63// Re-exported macros
64// ============================================================================
65/// Re-export GrpcError derive macro for automatic tonic::Status conversion
66#[cfg(feature = "router-grpc")]
67pub use allframe_macros::GrpcError;
68/// Re-export HealthCheck derive macro for automatic health check implementation
69#[cfg(feature = "di")]
70pub use allframe_macros::HealthCheck;
71/// Re-export async_graphql for GraphQL support
72#[cfg(feature = "router-graphql")]
73pub use async_graphql;
74/// Re-export async_graphql_parser for GraphQL parsing
75#[cfg(feature = "router-graphql")]
76pub use async_graphql_parser;
77/// Re-export async_trait for async trait definitions
78pub use async_trait;
79/// Re-export futures for async utilities
80#[cfg(feature = "router-grpc")]
81pub use futures;
82/// Re-export hyper for HTTP primitives
83pub use hyper;
84/// Re-export prost for protobuf support
85#[cfg(feature = "router-grpc")]
86pub use prost;
87/// Re-export prost_types for well-known protobuf types
88#[cfg(feature = "router-grpc")]
89pub use prost_types;
90/// Re-export serde for serialization
91pub use serde;
92/// Re-export serde_json for JSON handling
93pub use serde_json;
94/// Re-export tokio for async runtime
95pub use tokio;
96/// Re-export tokio_stream for async streams
97#[cfg(feature = "router-grpc")]
98pub use tokio_stream;
99/// Re-export tonic for gRPC support
100#[cfg(feature = "router-grpc")]
101pub use tonic;
102/// Re-export tonic_reflection for gRPC reflection
103#[cfg(feature = "router-grpc")]
104pub use tonic_reflection;
105/// Re-export tracing for observability
106#[cfg(feature = "otel")]
107pub use tracing;
108
109/// Prelude module for convenient imports
110///
111/// Commonly used imports for AllFrame applications
112pub mod prelude {
113 /// Re-export cache utilities
114 pub use crate::cache::{Cache, CacheConfig, CacheKey, MemoryCache};
115 /// Re-export DI utilities
116 #[cfg(feature = "di")]
117 pub use crate::di::{
118 AsyncInit, AsyncInitWith, ContainerBuilder, DependencyError, DependencyRegistry, FromEnv,
119 Provider, Scope,
120 };
121 /// Re-export gRPC server utilities
122 #[cfg(feature = "router-grpc")]
123 pub use crate::grpc::{GrpcServer, GrpcServerBuilder, GrpcServerError, TlsConfig};
124 /// Re-export health check utilities
125 pub use crate::health::{
126 Dependency, DependencyStatus, HealthCheck, HealthReport, HealthServer, OverallStatus,
127 SimpleHealthCheck,
128 };
129 pub use crate::router::{
130 GraphQLAdapter, GrpcAdapter, GrpcRequest, GrpcStatus, Method, ProtocolAdapter, RestAdapter,
131 RestRequest, RestResponse, RouteMetadata, Router, ToJsonSchema,
132 };
133 #[cfg(feature = "router")]
134 pub use crate::router::{GraphQLConfig, GrpcConfig, RestConfig, RouterConfig, ServerConfig};
135 /// Re-export shutdown utilities
136 pub use crate::shutdown::{GracefulShutdown, ShutdownSignal, ShutdownToken};
137 /// Re-export GrpcError for convenient error handling
138 #[cfg(feature = "router-grpc")]
139 pub use crate::GrpcError;
140}
141
142#[cfg(test)]
143mod tests {
144 #[test]
145 fn test_allframe_core_exists() {
146 // This test verifies the crate compiles
147 assert!(true);
148 }
149}