diff --git a/src/pcd.rs b/src/pcd.rs index 4df8a44..d1bcd2c 100644 --- a/src/pcd.rs +++ b/src/pcd.rs @@ -234,9 +234,10 @@ impl TryFrom for Pcd { fn try_from(value: Value) -> Result { let as_object = value.as_object().ok_or_else(|| Error::msg("Pcd must be an object"))?; - let map: Result>> = as_object.iter().map(|(key, value)| { - let serialized = crate::serialization::ciborium_serialize(value)?; - Ok((key.clone(), serialized)) + let map: Result>> = as_object.into_iter().map(|(key, value)| { + // Use the trait method instead of manual serialization + let compressed = value.serialize_to_pcd()?; + Ok((key.clone(), compressed)) }).collect(); Ok(Pcd(map?)) @@ -247,9 +248,10 @@ impl TryFrom> for Pcd { type Error = Error; fn try_from(file_blob_map: BTreeMap) -> Result { - let map: Result>> = file_blob_map.iter().map(|(key, value)| { - let serialized = crate::serialization::ciborium_serialize(value)?; - Ok((key.clone(), serialized)) + let map: Result>> = file_blob_map.into_iter().map(|(key, value)| { + // Use the trait method instead of manual serialization + let compressed = value.serialize_to_pcd()?; + Ok((key, compressed)) }).collect(); Ok(Pcd(map?))