Every stored certificate, as `(base32 id, document)` pairs. Unreadable files are skipped rather than failing the whole listing: one corrupt certificate should not make `atomic identity agent list` unusable.
(&self)
| 805 | /// corrupt certificate should not make `atomic identity agent list` |
| 806 | /// unusable. |
| 807 | pub fn list_delegations(&self) -> Result<Vec<(String, String)>, IdentityError> { |
| 808 | let dir = self.delegations_dir(); |
| 809 | if !dir.exists() { |
| 810 | return Ok(Vec::new()); |
| 811 | } |
| 812 | |
| 813 | let mut out = Vec::new(); |
| 814 | for entry in fs::read_dir(&dir)? { |
| 815 | let entry = entry?; |
| 816 | let name = entry.file_name(); |
| 817 | let Some(name) = name.to_str() else { continue }; |
| 818 | // Revocations sit beside certificates and share the id prefix. |
| 819 | if !name.ends_with(".json") || name.ends_with(".revocation.json") { |
| 820 | continue; |
| 821 | } |
| 822 | let id = name.trim_end_matches(".json").to_string(); |
| 823 | if let Ok(document) = fs::read_to_string(entry.path()) { |
| 824 | out.push((id, document)); |
| 825 | } |
| 826 | } |
| 827 | out.sort_by(|a, b| a.0.cmp(&b.0)); |
| 828 | Ok(out) |
| 829 | } |
| 830 | |
| 831 | /// Delete a certificate and any revocation stored alongside it. |
| 832 | pub fn delete_delegation(&self, id: &str) -> Result<(), IdentityError> { |