Skip to main content

genja_core/settings/
ssh.rs

1use serde::{Deserialize, Serialize};
2
3/// SSH client settings.
4///
5/// When `config_file` is set, `Settings::from_file` validates that the referenced
6/// OpenSSH-style config can be opened and parsed.
7#[derive(Deserialize, Serialize, Clone, Debug, Default)]
8#[serde(default)]
9pub struct SSHConfig {
10    pub(super) config_file: Option<String>,
11}
12
13impl SSHConfig {
14    pub fn builder() -> SSHConfigBuilder {
15        SSHConfigBuilder::default()
16    }
17
18    pub fn config_file(&self) -> Option<&str> {
19        self.config_file.as_deref()
20    }
21}
22
23/// Builder for `SSHConfig`.
24#[derive(Default)]
25pub struct SSHConfigBuilder {
26    config_file: Option<String>,
27}
28
29impl SSHConfigBuilder {
30    pub fn config_file(mut self, path: impl Into<String>) -> Self {
31        self.config_file = Some(path.into());
32        self
33    }
34
35    pub fn build(self) -> SSHConfig {
36        SSHConfig {
37            config_file: self.config_file,
38        }
39    }
40}