diff --git a/rust/pv/src/crypto.rs b/rust/pv/src/crypto.rs index 98a24da4..a589e963 100644 --- a/rust/pv/src/crypto.rs +++ b/rust/pv/src/crypto.rs @@ -760,7 +760,10 @@ mod tests { assert!(matches!( SymKey::try_from_data(SymKeyType::Aes256Gcm, Confidential::new([0x4u8; 33].into())), - Err(Error::PvCore(PvCoreError::LengthMismatch(33, 32))) + Err(Error::PvCore(PvCoreError::LengthMismatch { + expected: 32, + actual: 33 + })) )); } } diff --git a/rust/pv_core/src/confidential.rs b/rust/pv_core/src/confidential.rs index f17a0e3a..c9a04b19 100644 --- a/rust/pv_core/src/confidential.rs +++ b/rust/pv_core/src/confidential.rs @@ -182,7 +182,10 @@ impl TryFrom>> for Confidential<[u8; N]> { TryInto::<[u8; N]>::try_into(value.0.clone()).unwrap(), )) } else { - Err(Error::LengthMismatch(len, N)) + Err(Error::LengthMismatch { + expected: N, + actual: len, + }) } } } @@ -258,7 +261,13 @@ mod test { let result: Result, Error> = Confidential::new(data.clone()).try_into(); - assert!(matches!(result, Err(Error::LengthMismatch(100, 101)))); + assert!(matches!( + result, + Err(Error::LengthMismatch { + expected: 101, + actual: 100 + }) + )); } #[test] diff --git a/rust/pv_core/src/error.rs b/rust/pv_core/src/error.rs index 0cee8989..20fca24d 100644 --- a/rust/pv_core/src/error.rs +++ b/rust/pv_core/src/error.rs @@ -82,8 +82,8 @@ pub enum Error { #[error("Cannot decode hex string")] InvHexStringChar { source: std::num::ParseIntError }, - #[error("Expected size {0}, found {1}")] - LengthMismatch(usize, usize), + #[error("Expected size {expected}, actual {actual}")] + LengthMismatch { expected: usize, actual: usize }, } /// Error cases for I/O operations