hydra/
supervisor_options.rs1use std::time::Duration;
2
3use crate::GenServerOptions;
4
5#[derive(Debug, Default, Clone)]
7pub struct SupervisorOptions {
8 pub(crate) name: Option<String>,
9 pub(crate) timeout: Option<Duration>,
10}
11
12impl SupervisorOptions {
13 pub const fn new() -> Self {
15 Self {
16 name: None,
17 timeout: None,
18 }
19 }
20
21 pub fn name<T: Into<String>>(mut self, name: T) -> Self {
23 self.name = Some(name.into());
24 self
25 }
26
27 pub fn timeout(mut self, timeout: Duration) -> Self {
29 self.timeout = Some(timeout);
30 self
31 }
32}
33
34impl From<SupervisorOptions> for GenServerOptions {
35 fn from(mut value: SupervisorOptions) -> Self {
36 let mut options = GenServerOptions::new();
37
38 if let Some(name) = value.name.take() {
39 options = options.name(name);
40 }
41
42 if let Some(timeout) = value.timeout.take() {
43 options = options.timeout(timeout);
44 }
45
46 options
47 }
48}