pub struct ConfigService<'a> { /* private fields */ }Expand description
SSH config file operations.
Implementations§
Source§impl<'a> ConfigService<'a>
impl<'a> ConfigService<'a>
pub fn new(paths: &'a SshPaths) -> Self
Sourcepub async fn save(&self, ast: &ConfigAst) -> Result<()>
pub async fn save(&self, ast: &ConfigAst) -> Result<()>
Save the AST atomically with 0o600 permissions.
§Errors
Error::ConfigWriteFailed (write/rename) or Error::Io (chmod).
Sourcepub async fn resolve_host(&self, host: &str) -> Result<ResolvedHost>
pub async fn resolve_host(&self, host: &str) -> Result<ResolvedHost>
Resolve a host alias to a ResolvedHost, expanding Includes and
tokens.
§Errors
Sourcepub async fn parse_typed(&self) -> Result<SshConfig>
pub async fn parse_typed(&self) -> Result<SshConfig>
Parse the config into an ssh2_config_rs::SshConfig (supports
.query(host)).
§Errors
Sourcepub fn get_host_directive(
ast: &ConfigAst,
host: &str,
key: &str,
) -> Option<String>
pub fn get_host_directive( ast: &ConfigAst, host: &str, key: &str, ) -> Option<String>
Get a directive value for a host from the AST; first match wins.
Sourcepub fn get_all_host_directives(
ast: &ConfigAst,
host: &str,
) -> Vec<(String, String)>
pub fn get_all_host_directives( ast: &ConfigAst, host: &str, ) -> Vec<(String, String)>
Get all directives for a host.
Sourcepub fn add_host(
ast: &mut ConfigAst,
name: &str,
directives: Vec<(String, String)>,
) -> Result<()>
pub fn add_host( ast: &mut ConfigAst, name: &str, directives: Vec<(String, String)>, ) -> Result<()>
Sourcepub fn rename_host(
ast: &mut ConfigAst,
old_name: &str,
new_name: &str,
) -> Result<()>
pub fn rename_host( ast: &mut ConfigAst, old_name: &str, new_name: &str, ) -> Result<()>
Rename a Host block.
§Errors
Error::HostNotFound if old_name is absent, or
Error::DuplicateHost if new_name exists.
Sourcepub fn upsert_managed_block(
ast: &mut ConfigAst,
name: &str,
directives: Vec<(String, String)>,
)
pub fn upsert_managed_block( ast: &mut ConfigAst, name: &str, directives: Vec<(String, String)>, )
Add a managed block (or replace an existing one).
Sourcepub fn list_managed_blocks(ast: &ConfigAst) -> Vec<String>
pub fn list_managed_blocks(ast: &ConfigAst) -> Vec<String>
List all managed block names.
Sourcepub async fn ensure_config_file(&self) -> Result<()>
pub async fn ensure_config_file(&self) -> Result<()>
Sourcepub fn config_path(&self) -> &Path
pub fn config_path(&self) -> &Path
Get the path to the config file.
Auto Trait Implementations§
impl<'a> Freeze for ConfigService<'a>
impl<'a> RefUnwindSafe for ConfigService<'a>
impl<'a> Send for ConfigService<'a>
impl<'a> Sync for ConfigService<'a>
impl<'a> Unpin for ConfigService<'a>
impl<'a> UnsafeUnpin for ConfigService<'a>
impl<'a> UnwindSafe for ConfigService<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more