diff --git a/memory_storage/src/lib.rs b/memory_storage/src/lib.rs index 7c5191189..5ed0c3852 100644 --- a/memory_storage/src/lib.rs +++ b/memory_storage/src/lib.rs @@ -877,7 +877,11 @@ impl StorageProvider for MemoryStorage { group_id: &GroupId, ) -> Result { let key = serde_json::to_vec(group_id)?; - self.read(AAD_LABEL, &key) + match self.read(AAD_LABEL, &key) { + Ok(Some(data)) => Ok(data), + Ok(None) => Ok(ByteWrapper::from(Vec::new())), + Err(e) => Err(e), + } } fn write_aad< @@ -889,7 +893,7 @@ impl StorageProvider for MemoryStorage { aad: &ByteWrapper, ) -> Result<(), Self::Error> { let key = serde_json::to_vec(group_id)?; - self.write::(AAD_LABEL, &key, aad.to_vec()) + self.write::(AAD_LABEL, &key, serde_json::to_vec(aad).unwrap()) } fn delete_aad>( diff --git a/openmls/src/storage.rs b/openmls/src/storage.rs index ac75ed9a9..e1f590c83 100644 --- a/openmls/src/storage.rs +++ b/openmls/src/storage.rs @@ -63,6 +63,18 @@ struct ByteWrapper { data: Vec, } +impl ByteWrapper { + fn from(data: Vec) -> Self { + ByteWrapper { data } + } +} + +impl From> for ByteWrapper { + fn from(data: Vec) -> Self { + ByteWrapper { data } + } +} + impl Entity for ByteWrapper {} impl traits::ByteWrapper for ByteWrapper {} diff --git a/traits/src/storage.rs b/traits/src/storage.rs index ae842cb1b..e1e82760f 100644 --- a/traits/src/storage.rs +++ b/traits/src/storage.rs @@ -620,6 +620,7 @@ pub mod traits { pub trait EpochKey: Key {} // traits for entity, one per type + pub trait ByteWrapper: Entity {} pub trait QueuedProposal: Entity {} pub trait TreeSync: Entity {} pub trait GroupContext: Entity {}