Save the active gateway name to persistent storage.
(name: &str)
| 230 | |
| 231 | /// Save the active gateway name to persistent storage. |
| 232 | pub fn save_active_gateway(name: &str) -> Result<()> { |
| 233 | validated_gateway_name(name)?; |
| 234 | let path = user_active_gateway_path()?; |
| 235 | ensure_parent_dir_restricted(&path)?; |
| 236 | std::fs::write(&path, name) |
| 237 | .into_diagnostic() |
| 238 | .wrap_err_with(|| format!("failed to write active gateway to {}", path.display()))?; |
| 239 | Ok(()) |
| 240 | } |
| 241 | |
| 242 | fn read_gateway_name(path: &Path) -> Option<String> { |
| 243 | let value = read_nonempty_trimmed(path)?; |