1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use crate::*;
/// A generic trait for functions that take a `Context` and return a value.
///
/// This trait encapsulates the common behavior of being a sendable, synchronous
/// function that accepts a `Context`. It is used as a base for other, more
/// specific function traits.
/// A trait for functions that return a pinned, boxed, sendable future.
///
/// This trait is essential for creating type-erased async function pointers,
/// which is a common pattern for storing and dynamically dispatching different
/// asynchronous handlers in a collection.
/// A trait for static, sendable, synchronous functions that return a future.
///
/// This trait ensures that a hook function is safe to be sent across threads
/// and has a static lifetime, making it suitable for use in long-lived components
/// of the application, such as the main router.
/// A trait for futures that are sendable and have a static lifetime.
///
/// This marker trait simplifies generic bounds for asynchronous operations, ensuring
/// that futures can be safely managed by the async runtime without lifetime issues.
/// A trait for `Send`-able futures with a generic output.
///
/// This trait is used for asynchronous operations that need to be sendable across threads,
/// such as in the server's request processing pipeline.
/// A trait for thread-safe, reference-counted closures that produce a boxed future.
///
/// This trait is used for storing and executing asynchronous operations that need to be
/// sendable across threads, such as in the server's request processing pipeline.
/// Trait for server lifecycle hooks that process requests.
///
/// `ServerHook` provides a unified interface for different types of request processing
/// handlers in the server lifecycle, including route handlers, middleware, and panic hooks.
/// All hooks follow the same pattern: instantiation via `new` and execution via `handle`.
///
/// This trait is designed to work with the server's request processing pipeline, where
/// each hook receives the `Context` directly for both initialization and processing.