Skip to content

Commit

Permalink
fixed result/mapping and other minor
Browse files Browse the repository at this point in the history
  • Loading branch information
giannis-rdx committed Jan 30, 2025
1 parent 5c9af2b commit d699d2e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
30 changes: 17 additions & 13 deletions crates/profile/logic/logic_SPLIT_ME/src/logic/profile_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,39 +342,43 @@ pub trait ProfileSecurityStructuresUpdating {
fn update_security_structure_remove_flag_default(
&mut self,
shield_id: &SecurityStructureID,
) -> Result<bool>;
) -> Result<()>;

fn update_security_structure_add_flag_default(
&mut self,
shield_id: &SecurityStructureID,
) -> Result<bool>;
) -> Result<()>;
}

impl ProfileSecurityStructuresUpdating for Profile {
fn update_security_structure_remove_flag_default(
&mut self,
shield_id: &SecurityStructureID,
) -> Result<bool> {
Ok(self
.app_preferences
) -> Result<()> {
self.app_preferences
.security
.security_structures_of_factor_source_ids
.update_with(shield_id, |s| {
.try_update_with(shield_id, |s| {
s.metadata.remove_flag(SecurityStructureFlag::Default)
}))
})
.map_err(|_| CommonError::InvalidSecurityStructureID {
bad_value: shield_id.to_string(),

Check warning on line 365 in crates/profile/logic/logic_SPLIT_ME/src/logic/profile_update.rs

View check run for this annotation

Codecov / codecov/patch

crates/profile/logic/logic_SPLIT_ME/src/logic/profile_update.rs#L365

Added line #L365 was not covered by tests
})
}

fn update_security_structure_add_flag_default(
&mut self,
shield_id: &SecurityStructureID,
) -> Result<bool> {
Ok(self
.app_preferences
) -> Result<()> {
self.app_preferences
.security
.security_structures_of_factor_source_ids
.update_with(shield_id, |s| {
s.metadata.set_flag(SecurityStructureFlag::Default)
}))
.try_update_with(shield_id, |s| {
s.metadata.insert_flag(SecurityStructureFlag::Default)
})
.map_err(|_| CommonError::InvalidSecurityStructureID {
bad_value: shield_id.to_string(),

Check warning on line 380 in crates/profile/logic/logic_SPLIT_ME/src/logic/profile_update.rs

View check run for this annotation

Codecov / codecov/patch

crates/profile/logic/logic_SPLIT_ME/src/logic/profile_update.rs#L380

Added line #L380 was not covered by tests
})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@ impl SecurityStructureMetadata {
)
}

pub fn set_flag(&mut self, flag: SecurityStructureFlag) {
pub fn insert_flag(&mut self, flag: SecurityStructureFlag) {
self.flags.insert(flag);
}

pub fn remove_flag(&mut self, flag: SecurityStructureFlag) {
let result = self.flags.remove_id(&flag.id());
println!("flag removed: {:?}", result)
self.flags.remove_id(&flag.id());
}

pub fn is_default(&self) -> bool {
Expand Down

0 comments on commit d699d2e

Please sign in to comment.