Open the cache rooted at `dir` (used by tests).
(dir: &Path)
| 98 | |
| 99 | /// Open the cache rooted at `dir` (used by tests). |
| 100 | pub fn open_at(dir: &Path) -> Self { |
| 101 | let path = dir.to_path_buf().join(CACHE_FILE); |
| 102 | |
| 103 | if let Ok(raw) = std::fs::read_to_string(&path) { |
| 104 | match serde_json::from_str::<CacheFile>(&raw) { |
| 105 | Ok(file) => { |
| 106 | return Self { |
| 107 | dir: dir.to_path_buf(), |
| 108 | path, |
| 109 | entries: file.entries, |
| 110 | } |
| 111 | } |
| 112 | Err(e) => { |
| 113 | log::debug!("key cache unreadable (ignoring): {e}"); |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | Self { |
| 119 | dir: dir.to_path_buf(), |
| 120 | path, |
| 121 | entries: BTreeMap::new(), |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | /// Look up a cached, unexpired, active key for (server, identity name). |
| 126 | /// |
nothing calls this directly
no outgoing calls
no test coverage detected