From 292d97c8483e5385d564d422f433a0cbf9b8bad4 Mon Sep 17 00:00:00 2001 From: Thomas Avery Date: Tue, 2 Apr 2024 14:50:59 -0500 Subject: [PATCH] use require --- .../bitwarden/src/secrets_manager/secrets/sync.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/crates/bitwarden/src/secrets_manager/secrets/sync.rs b/crates/bitwarden/src/secrets_manager/secrets/sync.rs index 9a1df89ef..e2546022d 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/sync.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/sync.rs @@ -7,7 +7,7 @@ use uuid::Uuid; use super::SecretResponse; use crate::{ client::encryption_settings::EncryptionSettings, - error::{Error, Result}, + error::{require, Result}, Client, }; @@ -51,24 +51,19 @@ impl SecretsSyncResponse { response: SecretsSyncResponseModel, enc: &EncryptionSettings, ) -> Result { - let has_changes = response.has_changes.ok_or(Error::MissingFields)?; + let has_changes = require!(response.has_changes); - if has_changes && response.secrets.is_some() { - let secrets = response - .secrets - .unwrap() + if has_changes { + let secrets = require!(response.secrets) .data .unwrap_or_default() .into_iter() .map(|r| SecretResponse::process_base_response(r, enc)) .collect::>()?; - return Ok(SecretsSyncResponse { has_changes, secrets: Some(secrets), }); - } else if has_changes && response.secrets.is_none() { - return Err(Error::MissingFields); } Ok(SecretsSyncResponse {