Delete an identity from the store.
(&mut self, id: &IdentityId)
| 629 | |
| 630 | /// Delete an identity from the store. |
| 631 | pub fn delete(&mut self, id: &IdentityId) -> Result<(), IdentityError> { |
| 632 | let identity_dir = self.find_identity_dir(id)?; |
| 633 | |
| 634 | // Remove from defaults if set |
| 635 | if self.config.default_identity.as_ref() == Some(&id.to_base32()) { |
| 636 | self.config.default_identity = None; |
| 637 | } |
| 638 | |
| 639 | self.config |
| 640 | .default_by_usage |
| 641 | .retain(|_, v| v != &id.to_base32()); |
| 642 | |
| 643 | // Save updated config |
| 644 | self.save_config()?; |
| 645 | |
| 646 | // Remove the identity directory |
| 647 | fs::remove_dir_all(identity_dir)?; |
| 648 | |
| 649 | Ok(()) |
| 650 | } |
| 651 | |
| 652 | /// List all identities in the store. |
| 653 | pub fn list(&self) -> Result<Vec<Identity>, IdentityError> { |