tako_rs_core/lib.rs
1#![cfg_attr(docsrs, feature(doc_cfg))]
2// `FromRequest::from_request` and `FromRequestParts::from_request_parts` use the
3// `fn(...) -> impl Future + Send + 'a` shape on purpose: the explicit `+ Send`
4// bound is what lets handlers be hosted by the hyper service trait. Rewriting
5// these as `async fn` would drop the bound.
6#![allow(clippy::manual_async_fn)]
7
8//! Internal core for the Tako framework.
9//!
10//! This crate hosts the framework primitives shared across all Tako sub-crates:
11//! routing, request/response types, body, middleware/plugin traits, extractor
12//! traits, state, signals, queue, and a few cross-cutting features such as
13//! `graphql`, `grpc`, and `openapi` that interact tightly with the router.
14//!
15//! Concrete extractors live in `tako-extractors`, server bootstrap code in
16//! `tako-server`, streaming/upgrade transports in `tako-streams`, and concrete
17//! middleware/plugin implementations in `tako-plugins`. Users should depend on
18//! the `tako-rs` umbrella crate, which re-exports everything under the original
19//! `tako::*` paths.
20
21/// HTTP request and response body handling utilities.
22pub mod body;
23
24/// HTTP client implementation for making outbound requests.
25#[cfg(all(feature = "client", not(feature = "compio")))]
26#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
27pub mod client;
28
29/// Configuration loading from environment variables.
30pub mod config;
31
32/// Request data extraction trait + the two extractors (`json`, `params`)
33/// whose internal types are referenced by the router and route.
34pub mod extractors;
35
36/// Request handler traits and implementations.
37pub mod handler;
38
39/// Middleware trait + `Next` execution chain.
40pub mod middleware;
41
42/// Plugin system trait (`TakoPlugin`).
43#[cfg(feature = "plugins")]
44#[cfg_attr(docsrs, doc(cfg(feature = "plugins")))]
45pub mod plugins;
46
47/// Response generation utilities and traits.
48pub mod responder;
49
50/// RFC 7807 / RFC 9457 `application/problem+json` error responses.
51pub mod problem;
52
53/// Unified per-connection metadata extension shared by every transport.
54pub mod conn_info;
55
56/// Shared TLS certificate / key PEM loading helpers.
57#[cfg(any(feature = "tls", feature = "http3", feature = "client"))]
58#[cfg_attr(
59 docsrs,
60 doc(cfg(any(feature = "tls", feature = "http3", feature = "client")))
61)]
62pub mod tls;
63
64/// Redirection utilities for handling HTTP redirects.
65pub mod redirect;
66
67/// Route definition and matching logic.
68pub mod route;
69
70/// Request routing and dispatch functionality.
71pub mod router;
72
73/// In-memory background job queue with retry, delayed jobs, and dead letter support.
74pub mod queue;
75
76/// Application state management and dependency injection.
77pub mod state;
78
79/// Per-router typed state container (instance-scoped, complements `state`).
80pub mod router_state;
81
82#[cfg(feature = "signals")]
83/// In-process signal arbiter for custom events.
84pub mod signals;
85
86/// Distributed tracing integration for observability.
87#[cfg(feature = "tako-tracing")]
88#[cfg_attr(docsrs, doc(cfg(feature = "tako-tracing")))]
89pub mod tracing;
90
91/// Core type definitions used throughout the framework.
92pub mod types;
93
94/// `GraphQL` support (request extractors, responses, and subscriptions).
95#[cfg(feature = "async-graphql")]
96#[cfg_attr(docsrs, doc(cfg(feature = "async-graphql")))]
97pub mod graphql;
98
99/// `GraphiQL` UI helpers.
100#[cfg(feature = "graphiql")]
101#[cfg_attr(docsrs, doc(cfg(feature = "graphiql")))]
102pub mod graphiql;
103
104/// `OpenAPI` documentation generation integrations (utoipa, vespera).
105#[cfg(any(feature = "utoipa", feature = "vespera"))]
106#[cfg_attr(docsrs, doc(cfg(any(feature = "utoipa", feature = "vespera"))))]
107pub mod openapi;
108
109/// gRPC support for unary RPCs with protobuf serialization.
110#[cfg(feature = "grpc")]
111#[cfg_attr(docsrs, doc(cfg(feature = "grpc")))]
112pub mod grpc;
113
114pub use bytes::Bytes;
115pub use http::Method;
116pub use http::StatusCode;
117pub use http::header;
118pub use http_body_util::Full;
119pub use responder::NOT_FOUND;