@@ -5,6 +5,10 @@ use std::{fmt, str::FromStr};
55use blake2b_simd:: Params ;
66use displaydoc:: Display ;
77use pallas_crypto:: hash:: Hash ;
8+ use scylla:: _macro_internal:: {
9+ CellWriter , ColumnType , DeserializationError , DeserializeValue , FrameSlice , SerializationError ,
10+ SerializeValue , TypeCheckError , WrittenCellProof ,
11+ } ;
812use thiserror:: Error ;
913
1014/// Number of bytes in a blake2b 224 hash.
@@ -165,6 +169,29 @@ impl<'a, C, const BYTES: usize> minicbor::Decode<'a, C> for Blake2bHash<BYTES> {
165169 }
166170}
167171
172+ impl < const BYTES : usize > SerializeValue for Blake2bHash < BYTES > {
173+ fn serialize < ' b > (
174+ & self , typ : & ColumnType , writer : CellWriter < ' b > ,
175+ ) -> Result < WrittenCellProof < ' b > , SerializationError > {
176+ self . 0 . as_ref ( ) . serialize ( typ, writer)
177+ }
178+ }
179+
180+ impl < ' frame , ' metadata , const BYTES : usize > DeserializeValue < ' frame , ' metadata >
181+ for Blake2bHash < BYTES >
182+ {
183+ fn type_check ( typ : & ColumnType ) -> Result < ( ) , TypeCheckError > {
184+ <Vec < u8 > >:: type_check ( typ)
185+ }
186+
187+ fn deserialize (
188+ typ : & ' metadata ColumnType < ' metadata > , v : Option < FrameSlice < ' frame > > ,
189+ ) -> Result < Self , DeserializationError > {
190+ let bytes = <Vec < u8 > >:: deserialize ( typ, v) ?;
191+ Self :: try_from ( bytes) . map_err ( DeserializationError :: new)
192+ }
193+ }
194+
168195#[ cfg( test) ]
169196mod tests {
170197 use super :: * ;
0 commit comments