pub struct Config { /* private fields */ }
Expand description
A context for resolving configuration values. Holds a combination of environment and token expansion state, as well as the set of configs that should be consulted.
Implementations§
Source§impl Config
impl Config
Sourcepub fn assign_environment(&mut self, env: ConfigMap)
pub fn assign_environment(&mut self, env: ConfigMap)
Assign a fake environment map, useful for testing. The environment is used to expand certain values from the config.
Sourcepub fn assign_tokens(&mut self, tokens: ConfigMap)
pub fn assign_tokens(&mut self, tokens: ConfigMap)
Assigns token names and expansions for use with a number of
options. The names and expansions are specified
by man 5 ssh_config
Sourcepub fn set_option<K: AsRef<str>, V: AsRef<str>>(&mut self, key: K, value: V)
pub fn set_option<K: AsRef<str>, V: AsRef<str>>(&mut self, key: K, value: V)
Assign the value for an option. This is logically equivalent to the user specifying command line options to override config values. These values take precedence over any values found in config files.
Sourcepub fn add_config_string(&mut self, config_string: &str)
pub fn add_config_string(&mut self, config_string: &str)
Parse config_string
as if it were the contents of an ssh_config
file,
and add that to the list of configs.
Sourcepub fn add_config_file<P: AsRef<Path>>(&mut self, path: P)
pub fn add_config_file<P: AsRef<Path>>(&mut self, path: P)
Open path
, read its contents and parse it as an ssh_config
file,
adding that to the list of configs
Sourcepub fn add_default_config_files(&mut self)
pub fn add_default_config_files(&mut self)
Convenience method for adding the ~/.ssh/config and system-wide
/etc/ssh/config
files to the list of configs
Sourcepub fn for_host<H: AsRef<str>>(&self, host: H) -> ConfigMap
pub fn for_host<H: AsRef<str>>(&self, host: H) -> ConfigMap
Resolve the configuration for a given host.
The returned map will expand environment and tokens for options
where that is specified.
Note that in some configurations, the config should be parsed once
to resolve the main configuration, and then based on some options
(such as CanonicalHostname), the tokens should be updated and
the config parsed a second time in order for value expansion
to have the same results as ssh
.