Skip to main content

hyperlane/config/
impl.rs

1use crate::*;
2
3/// Provides a default implementation for ServerConfig.
4impl Default for ServerConfig {
5    /// Creates a new ServerConfig instance with default values.
6    ///
7    /// # Returns
8    ///
9    /// - `Self` - A new instance with default configuration.
10    #[inline(always)]
11    fn default() -> Self {
12        Self {
13            address: Server::format_bind_address(DEFAULT_HOST, DEFAULT_WEB_PORT),
14            nodelay: DEFAULT_NODELAY,
15            ttl: DEFAULT_TTI,
16        }
17    }
18}
19
20/// Implementation block for ServerConfig.
21impl ServerConfig {
22    /// Creates a ServerConfig from a JSON string.
23    ///
24    /// # Arguments
25    ///
26    /// - `AsRef<str>` - The configuration.
27    ///
28    /// # Returns
29    ///
30    /// - `Result<Self, serde_json::Error>` - A `Result` containing either the `ServerConfig` or a `serde_json::Error`.
31    pub fn from_json<C>(json: C) -> Result<Self, serde_json::Error>
32    where
33        C: AsRef<str>,
34    {
35        serde_json::from_str(json.as_ref())
36    }
37}