hydra/
gen_server_options.rs

1use std::time::Duration;
2
3/// Options used to configure a GenServer.
4#[derive(Debug, Default, Clone)]
5pub struct GenServerOptions {
6    pub(crate) name: Option<String>,
7    pub(crate) timeout: Option<Duration>,
8}
9
10impl GenServerOptions {
11    /// Constructs a new instance of [GenServerOptions] with the default values.
12    pub const fn new() -> Self {
13        Self {
14            name: None,
15            timeout: None,
16        }
17    }
18
19    /// Specifies a name to register the GenServer under.
20    pub fn name<T: Into<String>>(mut self, name: T) -> Self {
21        self.name = Some(name.into());
22        self
23    }
24
25    /// Specifies a timeout for the GenServer `init` function.
26    pub fn timeout(mut self, timeout: Duration) -> Self {
27        self.timeout = Some(timeout);
28        self
29    }
30}