Skip to main content

hyperlane_core/hook/
struct.rs

1use super::*;
2
3/// Default server hook
4#[derive(
5    Clone,
6    Copy,
7    Debug,
8    Deserialize,
9    DisplayDebug,
10    Eq,
11    Hash,
12    Ord,
13    PartialEq,
14    PartialOrd,
15    Serialize,
16    Default,
17)]
18pub struct DefaultServerHook;
19
20/// Namespace for hook handler factory and utility functions.
21///
22/// This zero-size struct provides associated functions for creating
23/// and managing hook handlers in a semantically organized way.
24#[derive(
25    Clone,
26    Copy,
27    Debug,
28    Deserialize,
29    DisplayDebug,
30    Eq,
31    Hash,
32    Ord,
33    PartialEq,
34    PartialOrd,
35    Serialize,
36    Default,
37)]
38pub struct Hook;
39
40/// Represents the hooks for managing the server's lifecycle, specifically for waiting and shutting down.
41#[derive(Clone, CustomDebug, DisplayDebug, Getter, Setter)]
42pub struct ServerControlHook {
43    /// A hook that returns a future, which completes when the server's main task finishes.
44    /// This is typically used to wait for the server to stop accepting connections before
45    /// the application exits.
46    #[debug(skip)]
47    #[set(pub(crate))]
48    pub(super) wait_hook: ServerControlHookHandler<()>,
49    /// A hook that, when called, initiates a graceful shutdown of the server.
50    /// This will stop the server from accepting new connections and allow existing ones
51    /// to complete.
52    #[debug(skip)]
53    #[set(pub(crate))]
54    pub(super) shutdown_hook: ServerControlHookHandler<()>,
55}