Skip to content

Commit

Permalink
chore: remove unused code
Browse files Browse the repository at this point in the history
refactor: remove unused code
  • Loading branch information
alexng353 committed Sep 3, 2024
1 parent 74c3c2e commit b00b38d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 33 deletions.
6 changes: 1 addition & 5 deletions src/commands/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ pub async fn command(args: Args) -> Result<()> {
let id = SDK::new_user(&username, &key.public_key()?).await?;
println!("UUID: {}", &id);

for k in config.keys.iter_mut() {
if k.fingerprint == key.fingerprint {
k.uuid = Some(id.clone());
}
}
config.set_uuid(&key.fingerprint, &id)?;

config.write()?;

Expand Down
18 changes: 0 additions & 18 deletions src/utils/btreemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ pub trait ToBTreeMap {
fn to_btreemap(&self) -> Result<BTreeMap<String, String>>;
}

pub trait FromBTreeMap {
fn from_btreemap(map: &BTreeMap<String, String>) -> Result<Self>
where
Self: Sized;
}

impl ToBTreeMap for Config {
fn to_btreemap(&self) -> Result<BTreeMap<String, String>> {
// Convert Config to JSON value
Expand Down Expand Up @@ -43,18 +37,6 @@ impl ToBTreeMap for Settings {
}
}

impl FromBTreeMap for Settings {
fn from_btreemap(map: &BTreeMap<String, String>) -> Result<Self> {
// Convert BTreeMap to JSON value
let v: Value = serde_json::to_value(map)
.context("Failed to convert BTreeMap to JSON value")?;

// Convert JSON value into Settings
serde_json::from_value(v)
.context("Failed to convert JSON value to Settings")
}
}

impl ToBTreeMap for Vec<Key> {
fn to_btreemap(&self) -> Result<BTreeMap<String, String>> {
let mut map = BTreeMap::new();
Expand Down
11 changes: 7 additions & 4 deletions src/utils/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,13 @@ impl Config {
}

pub fn set_uuid(&mut self, fingerprint: &str, uuid: &str) -> Result<()> {
let mut key = Self::get_key(self, fingerprint)?.clone();
self.keys.retain(|k| k.fingerprint != fingerprint);
key.uuid = Some(uuid.to_string());
self.keys.push(key);
for k in self.keys.iter_mut() {
if k.fingerprint == fingerprint {
k.uuid = Some(uuid.to_string());
return Ok(());
}
}

Ok(())
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/utils/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ impl Settings {
pub fn set_keyring_expiry_never(&mut self) {
self.keyring_expiry = Some(KeyringExpiry::Never);
}
pub fn set_warn_on_short_passwords(&mut self, warn: bool) {
self.warn_on_short_passwords = warn;
}
pub fn get_keyring_expiry_days(&self) -> Option<u32> {
match self.keyring_expiry {
Some(KeyringExpiry::Days(d)) => Some(d),
Expand Down
5 changes: 2 additions & 3 deletions src/utils/variable.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::kvpair::KVPair;
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, fmt::Display};

use super::kvpair::KVPair;
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct EncryptedVariable {
pub id: String,
Expand All @@ -21,8 +22,6 @@ pub trait DeDupe {
fn dedupe(&self) -> Self;
}

use std::{collections::HashMap, fmt::Display};

impl DeDupe for Vec<DecryptedVariable> {
fn dedupe(&self) -> Self {
let mut sorted_vec = self.clone();
Expand Down

0 comments on commit b00b38d

Please sign in to comment.