pub fn deserialize<'de, D>(deserializer: D) -> Result<Hash, D::Error>
where
    D: Deserializer<'de>,
{
    let s = Option::<String>::deserialize(deserializer)?.unwrap_or_default();
    let decoded = base64::decode(&s).map_err(serde::de::Error::custom)?;
    if decoded.len() != HASH_LENGTH {
        return Err(serde::de::Error::custom(
            "unexpected transaction length for hash",
        ));
    }
    let mut decoded_bytes = [0u8; HASH_LENGTH];
    decoded_bytes.copy_from_slice(decoded.as_ref());
    Ok(Hash::new(decoded_bytes))
}
/// Deserialize a base64-encoded string into a Hash
Deserialize a base64-encoded string into a Hash
Deserialize a base64 - encoded string into a Hash
pub fn deserialize<'de, D>(deserializer: D) -> Result<Hash, D::Error>
where
    D: Deserializer<'de>,
{
    let s = Option::<String>::deserialize(deserializer)?.unwrap_or_default();
    let decoded = base64::decode(&s).map_err(serde::de::Error::custom)?;
    if decoded.len() != HASH_LENGTH {
        return Err(serde::de::Error::custom(
            "unexpected transaction length for hash",
        ));
    }
    let mut decoded_bytes = [0u8; HASH_LENGTH];
    decoded_bytes.copy_from_slice(decoded.as_ref());
    Ok(Hash::new(decoded_bytes))
}
pub fn deserialize < ' de , D > ( deserializer : D ) -> Result < Hash , D :: Error > where D : Deserializer < ' de > , { let s = Option :: < String > :: deserialize ( deserializer ) ? . unwrap_or_default ( ) ; let decoded = base64 :: decode ( & s ) . map_err ( serde :: de :: Error :: custom ) ? ; if decoded . len ( ) != HASH_LENGTH { return Err ( serde :: de :: Error :: custom ( " " , ) ) ; } let mut decoded_bytes = [ 0u8 ; HASH_LENGTH ] ; decoded_bytes . copy_from_slice ( decoded . as_ref ( ) ) ; Ok ( Hash :: new ( decoded_bytes ) ) }
Deserialize a base64-encoded string into a Hash
Deserialize a base64 - encoded string into a Hash
deserializer
D