AccountManagementView

View used to add and remove accounts from the app

Signed-off-by: kernelkind <kernelkind@gmail.com>
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
kernelkind
2024-05-09 15:21:02 -04:00
committed by William Casarin
parent 93800e0d04
commit e9c3596067
9 changed files with 555 additions and 3 deletions

48
src/key_storage.rs Normal file
View File

@@ -0,0 +1,48 @@
use nostr_sdk::Keys;
pub enum KeyStorage {
None,
// TODO:
// Linux,
// Windows,
// Android,
}
impl KeyStorage {
pub fn get_keys(&self) -> Result<Vec<Keys>, KeyStorageError> {
match self {
Self::None => Ok(Vec::new()),
}
}
pub fn add_key(&self, key: &Keys) -> Result<(), KeyStorageError> {
match self {
Self::None => Ok(()),
}
}
pub fn remove_key(&self, key: &Keys) -> Result<(), KeyStorageError> {
match self {
Self::None => Ok(()),
}
}
}
#[derive(Debug, PartialEq)]
pub enum KeyStorageError<'a> {
Retrieval,
Addition(&'a Keys),
Removal(&'a Keys),
}
impl std::fmt::Display for KeyStorageError<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::Retrieval => write!(f, "Failed to retrieve keys."),
Self::Addition(key) => write!(f, "Failed to add key: {:?}", key.public_key()),
Self::Removal(key) => write!(f, "Failed to remove key: {:?}", key.public_key()),
}
}
}
impl std::error::Error for KeyStorageError<'_> {}