Skip to main content

hyperlane/config/
struct.rs

1use crate::*;
2
3/// Represents the inner, mutable server configuration.
4///
5/// This structure holds all the settings for the HTTP and WebSocket server,
6/// including network parameters and buffer sizes. It is not intended to be used directly
7/// by end-users, but rather through the `ServerConfig` wrapper.
8#[derive(Clone, Data, CustomDebug, DisplayDebug, PartialEq, Eq, Deserialize, Serialize)]
9pub(crate) struct ServerConfigData {
10    /// The host address the server will bind to.
11    #[get(pub(crate))]
12    #[get_mut(pub(super))]
13    #[set(pub(super), type(AsRef<str>))]
14    pub(super) host: String,
15    /// The port number the server will listen on.
16    #[get(pub(crate), type(copy))]
17    #[get_mut(pub(super))]
18    #[set(pub(super))]
19    pub(super) port: u16,
20    /// The `TCP_NODELAY` option for sockets.
21    #[get(pub(crate))]
22    #[get_mut(pub(super))]
23    #[set(pub(super))]
24    pub(super) nodelay: Option<bool>,
25    /// The `IP_TTL` option for sockets.
26    #[get(pub(crate))]
27    #[get_mut(pub(super))]
28    #[set(pub(super))]
29    pub(super) ttl: Option<u32>,
30}
31
32/// Represents the thread-safe, shareable server configuration.
33///
34/// This structure wraps `ServerConfigData` in an `Arc<RwLock<ServerConfigData>>`
35/// to allow for safe concurrent access and modification of the server settings.
36#[derive(Clone, Getter, CustomDebug, DisplayDebug)]
37pub struct ServerConfig(#[get(pub(super))] pub(super) ArcRwLock<ServerConfigData>);