diff --git a/waku-bindings/src/general/messagehash.rs b/waku-bindings/src/general/messagehash.rs index 6b199a9..e236d4c 100644 --- a/waku-bindings/src/general/messagehash.rs +++ b/waku-bindings/src/general/messagehash.rs @@ -1,6 +1,6 @@ use crate::general::waku_decode::WakuDecode; use hex::FromHex; -use serde::{Deserialize, Deserializer, Serialize}; +use serde::{Deserialize, Serialize}; use std::convert::TryInto; use std::fmt; use std::fmt::Write; @@ -8,7 +8,7 @@ use std::hash::Hash; use std::str::FromStr; /// Waku message hash, hex encoded sha256 digest of the message -#[derive(Debug, Serialize, PartialEq, Eq, Clone, Hash)] +#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone, Hash)] pub struct MessageHash([u8; 32]); impl MessageHash { @@ -38,23 +38,6 @@ impl FromStr for MessageHash { } } -impl<'de> Deserialize<'de> for MessageHash { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - // Deserialize the input as a vector of u8 - let vec: Vec = Deserialize::deserialize(deserializer)?; - - // Ensure the vector has exactly 32 elements - let array: [u8; 32] = vec - .try_into() - .map_err(|_| serde::de::Error::custom("Expected an array of length 32"))?; - - Ok(MessageHash(array)) - } -} - impl WakuDecode for MessageHash { fn decode(input: &str) -> Result { MessageHash::from_str(input)