pub struct SshConfigFile {
pub elements: Vec<ConfigElement>,
pub path: PathBuf,
}Expand description
Represents the entire SSH config file as a sequence of elements. Preserves the original structure for round-trip fidelity.
Fields§
§elements: Vec<ConfigElement>§path: PathBufImplementations§
Source§impl SshConfigFile
impl SshConfigFile
Sourcepub fn host_entries(&self) -> Vec<HostEntry>
pub fn host_entries(&self) -> Vec<HostEntry>
Get all host entries as convenience views (including from Include files).
Sourcepub fn has_host(&self, alias: &str) -> bool
pub fn has_host(&self, alias: &str) -> bool
Check if a host alias already exists (including in Include files). Walks the element tree directly without building HostEntry structs.
Sourcepub fn update_host(&mut self, old_alias: &str, entry: &HostEntry)
pub fn update_host(&mut self, old_alias: &str, entry: &HostEntry)
Update an existing host entry by alias. Merges changes into the existing block, preserving unknown directives.
Set tags on a host block by alias.
Sourcepub fn delete_host(&mut self, alias: &str)
pub fn delete_host(&mut self, alias: &str)
Delete a host entry by alias.
Sourcepub fn delete_host_undoable(
&mut self,
alias: &str,
) -> Option<(ConfigElement, usize)>
pub fn delete_host_undoable( &mut self, alias: &str, ) -> Option<(ConfigElement, usize)>
Delete a host and return the removed element and its position for undo. Does NOT collapse blank lines so the position stays valid for re-insertion.
Sourcepub fn insert_host_at(&mut self, element: ConfigElement, position: usize)
pub fn insert_host_at(&mut self, element: ConfigElement, position: usize)
Insert a host block at a specific position (for undo).
Sourcepub fn swap_hosts(&mut self, alias_a: &str, alias_b: &str) -> bool
pub fn swap_hosts(&mut self, alias_a: &str, alias_b: &str) -> bool
Swap two host blocks in the config by alias. Returns true if swap was performed.
Source§impl SshConfigFile
impl SshConfigFile
Sourcepub fn parse(path: &Path) -> Result<Self>
pub fn parse(path: &Path) -> Result<Self>
Parse an SSH config file from the given path. Preserves all formatting, comments, and unknown directives for round-trip fidelity.
Sourcepub fn parse_content(content: &str) -> Vec<ConfigElement>
pub fn parse_content(content: &str) -> Vec<ConfigElement>
Parse SSH config content from a string (without Include resolution). Used by tests to create SshConfigFile from inline strings.
Trait Implementations§
Source§impl Clone for SshConfigFile
impl Clone for SshConfigFile
Source§fn clone(&self) -> SshConfigFile
fn clone(&self) -> SshConfigFile
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more