move account_manager t use keystorage result type
This commit is contained in:
parent
0e12af0505
commit
827be9a297
1 changed files with 7 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
|||
use crate::keystorage::{Error, KeyStorage, KeyStorageType};
|
||||
use crate::keystorage::{Result, KeyStorage, KeyStorageType};
|
||||
use nostr::Keys;
|
||||
|
||||
pub struct AccountManager {
|
||||
|
@ -12,14 +12,14 @@ impl AccountManager {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn generate_keys(&mut self) -> Result<Keys, Error> {
|
||||
pub fn generate_keys(&mut self) -> Result<Keys> {
|
||||
let new_keypair = Keys::generate();
|
||||
self.loaded_keys.push(new_keypair.clone());
|
||||
|
||||
Ok(new_keypair)
|
||||
}
|
||||
|
||||
pub fn load_keys(&mut self) -> Result<Vec<Keys>, Error> {
|
||||
pub fn load_keys(&mut self) -> Result<Vec<Keys>> {
|
||||
let mut keys = self.get_keys()?;
|
||||
keys.append(&mut self.loaded_keys);
|
||||
keys.dedup();
|
||||
|
@ -28,7 +28,7 @@ impl AccountManager {
|
|||
Ok(keys)
|
||||
}
|
||||
|
||||
pub fn delete_key(&mut self, key: &Keys) -> Result<(), Error> {
|
||||
pub fn delete_key(&mut self, key: &Keys) -> Result<()> {
|
||||
self.remove_key(key)?;
|
||||
if let Some(index) = self.loaded_keys.iter().position(|k| k == key) {
|
||||
self.loaded_keys.remove(index);
|
||||
|
@ -55,15 +55,15 @@ impl AccountManager {
|
|||
}
|
||||
|
||||
impl KeyStorage for AccountManager {
|
||||
fn get_keys(&self) -> Result<Vec<Keys>, Error> {
|
||||
fn get_keys(&self) -> Result<Vec<Keys>> {
|
||||
Self::get_platform_keystorage().get_keys()
|
||||
}
|
||||
|
||||
fn add_key(&self, key: &Keys) -> Result<(), Error> {
|
||||
fn add_key(&self, key: &Keys) -> Result<()> {
|
||||
Self::get_platform_keystorage().add_key(key)
|
||||
}
|
||||
|
||||
fn remove_key(&self, key: &Keys) -> Result<(), Error> {
|
||||
fn remove_key(&self, key: &Keys) -> Result<()> {
|
||||
Self::get_platform_keystorage().remove_key(key)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue