File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use std::{
55 fmt:: Debug ,
66 hash:: Hash ,
77 io:: { Read , Write } ,
8+ num:: NonZeroUsize ,
89} ;
910
1011use leb128;
@@ -334,6 +335,26 @@ impl Serializable for usize {
334335 }
335336}
336337
338+ impl Serializable for NonZeroUsize {
339+ type Error = CryptoCoreError ;
340+
341+ fn length ( & self ) -> usize {
342+ self . get ( ) . length ( )
343+ }
344+
345+ fn write ( & self , ser : & mut Serializer ) -> Result < usize , Self :: Error > {
346+ self . get ( ) . write ( ser)
347+ }
348+
349+ fn read ( de : & mut Deserializer ) -> Result < Self , Self :: Error > {
350+ Self :: new ( de. read ( ) ?) . ok_or_else ( || {
351+ Self :: Error :: GenericDeserializationError (
352+ "null value read while a non-zero value was expected" . to_string ( ) ,
353+ )
354+ } )
355+ }
356+ }
357+
337358impl Serializable for String {
338359 type Error = CryptoCoreError ;
339360
You can’t perform that action at this time.
0 commit comments