Delete an identity from the store.
(&mut self, id: &IdentityId)
| 695 | |
| 696 | /// Delete an identity from the store. |
| 697 | pub fn delete(&mut self, id: &IdentityId) -> Result<(), IdentityError> { |
| 698 | let identity_dir = self.find_identity_dir(id)?; |
| 699 | |
| 700 | // Remove from defaults if set |
| 701 | if self.config.default_identity.as_ref() == Some(&id.to_base32()) { |
| 702 | self.config.default_identity = None; |
| 703 | } |
| 704 | |
| 705 | self.config |
| 706 | .default_by_usage |
| 707 | .retain(|_, v| v != &id.to_base32()); |
| 708 | |
| 709 | // Save updated config |
| 710 | self.save_config()?; |
| 711 | |
| 712 | // Remove the identity directory |
| 713 | fs::remove_dir_all(identity_dir)?; |
| 714 | |
| 715 | Ok(()) |
| 716 | } |
| 717 | |
| 718 | /// List all identities in the store. |
| 719 | pub fn list(&self) -> Result<Vec<Identity>, IdentityError> { |