Implement deref on the IKM list, mainly to allow iteration over IKMs
This commit is contained in:
parent
395703dae4
commit
15198f5286
2 changed files with 24 additions and 1 deletions
23
src/ikm.rs
23
src/ikm.rs
|
@ -158,6 +158,15 @@ impl InputKeyMaterialList {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "ikm-management")]
|
||||
impl std::ops::Deref for InputKeyMaterialList {
|
||||
type Target = Vec<InputKeyMaterial>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.ikm_lst
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
@ -331,6 +340,20 @@ mod tests {
|
|||
assert!(res.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "ikm-management")]
|
||||
fn iterate() {
|
||||
let mut lst = InputKeyMaterialList::new();
|
||||
for _ in 0..10 {
|
||||
let _ = lst.add_ikm();
|
||||
}
|
||||
let mut id = 1;
|
||||
for ikm in lst.iter() {
|
||||
assert_eq!(id, ikm.id);
|
||||
id += 1;
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "encryption")]
|
||||
fn get_latest_ikm() {
|
||||
|
|
|
@ -15,7 +15,7 @@ mod storage;
|
|||
pub use encryption::{decrypt, encrypt};
|
||||
pub use error::Error;
|
||||
#[cfg(any(feature = "encryption", feature = "ikm-management"))]
|
||||
pub use ikm::{InputKeyMaterialList, InputKeyMaterial, IkmId};
|
||||
pub use ikm::{IkmId, InputKeyMaterial, InputKeyMaterialList};
|
||||
#[cfg(any(feature = "encryption", feature = "ikm-management"))]
|
||||
pub use scheme::Scheme;
|
||||
|
||||
|
|
Loading…
Reference in a new issue