Save tokens to file
(&self)
| 60 | |
| 61 | /// Save tokens to file |
| 62 | pub fn save(&self) -> io::Result<()> { |
| 63 | let Some(path) = Self::auth_path() else { |
| 64 | return Err(io::Error::new( |
| 65 | io::ErrorKind::NotFound, |
| 66 | "Could not determine config directory", |
| 67 | )); |
| 68 | }; |
| 69 | |
| 70 | if let Some(parent) = path.parent() { |
| 71 | fs::create_dir_all(parent)?; |
| 72 | } |
| 73 | |
| 74 | let contents = serde_json::to_string_pretty(self) |
| 75 | .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; |
| 76 | |
| 77 | fs::write(path, contents) |
| 78 | } |
| 79 | |
| 80 | /// Delete stored tokens |
| 81 | pub fn delete() -> io::Result<()> { |
no outgoing calls
no test coverage detected