Skip to main content

purple_ssh/app/
file_browser_state.rs

1use std::collections::HashMap;
2use std::path::PathBuf;
3
4/// Persistent per-host file-browser state: last-visited paths per alias.
5#[derive(Debug, Default, Clone)]
6pub struct FileBrowserState {
7    pub(in crate::app) host_paths: HashMap<String, (PathBuf, String)>,
8}
9
10impl FileBrowserState {
11    pub fn host_path(&self, alias: &str) -> Option<&(PathBuf, String)> {
12        self.host_paths.get(alias)
13    }
14
15    pub fn contains_host(&self, alias: &str) -> bool {
16        self.host_paths.contains_key(alias)
17    }
18
19    pub fn set_host_path(&mut self, alias: String, local: PathBuf, remote: String) {
20        self.host_paths.insert(alias, (local, remote));
21    }
22}