@@ -449,15 +449,96 @@ where
449449 }
450450
451451 fn write ( & self , ser : & mut Serializer ) -> Result < usize , Self :: Error > {
452- let mut n = self
452+ Ok ( self
453453 . 0
454454 . write ( ser)
455- . map_err ( |e| Self :: Error :: GenericSerializationError ( e. to_string ( ) ) ) ?;
456- n += self
457- . 1
455+ . map_err ( |e| Self :: Error :: GenericSerializationError ( e. to_string ( ) ) ) ?
456+ + self
457+ . 1
458+ . write ( ser)
459+ . map_err ( |e| Self :: Error :: GenericSerializationError ( e. to_string ( ) ) ) ?)
460+ }
461+
462+ fn read ( de : & mut Deserializer ) -> Result < Self , Self :: Error > {
463+ Ok ( (
464+ de. read ( )
465+ . map_err ( |e : T1 :: Error | Self :: Error :: GenericDeserializationError ( e. to_string ( ) ) ) ?,
466+ de. read ( )
467+ . map_err ( |e : T2 :: Error | Self :: Error :: GenericDeserializationError ( e. to_string ( ) ) ) ?,
468+ ) )
469+ }
470+ }
471+
472+ impl < T1 : Serializable , T2 : Serializable , T3 : Serializable > Serializable for ( T1 , T2 , T3 )
473+ where
474+ T1 :: Error : From < CryptoCoreError > ,
475+ T2 :: Error : From < CryptoCoreError > ,
476+ T3 :: Error : From < CryptoCoreError > ,
477+ {
478+ type Error = CryptoCoreError ;
479+
480+ fn length ( & self ) -> usize {
481+ self . 0 . length ( ) + self . 1 . length ( ) + self . 1 . length ( )
482+ }
483+
484+ fn write ( & self , ser : & mut Serializer ) -> Result < usize , Self :: Error > {
485+ Ok ( self
486+ . 0
487+ . write ( ser)
488+ . map_err ( |e| Self :: Error :: GenericSerializationError ( e. to_string ( ) ) ) ?
489+ + self
490+ . 1
491+ . write ( ser)
492+ . map_err ( |e| Self :: Error :: GenericSerializationError ( e. to_string ( ) ) ) ?
493+ + self
494+ . 2
495+ . write ( ser)
496+ . map_err ( |e| Self :: Error :: GenericSerializationError ( e. to_string ( ) ) ) ?)
497+ }
498+
499+ fn read ( de : & mut Deserializer ) -> Result < Self , Self :: Error > {
500+ Ok ( (
501+ de. read ( )
502+ . map_err ( |e : T1 :: Error | Self :: Error :: GenericDeserializationError ( e. to_string ( ) ) ) ?,
503+ de. read ( )
504+ . map_err ( |e : T2 :: Error | Self :: Error :: GenericDeserializationError ( e. to_string ( ) ) ) ?,
505+ de. read ( )
506+ . map_err ( |e : T3 :: Error | Self :: Error :: GenericDeserializationError ( e. to_string ( ) ) ) ?,
507+ ) )
508+ }
509+ }
510+
511+ impl < T1 : Serializable , T2 : Serializable , T3 : Serializable , T4 : Serializable > Serializable
512+ for ( T1 , T2 , T3 , T4 )
513+ where
514+ T1 :: Error : From < CryptoCoreError > ,
515+ T2 :: Error : From < CryptoCoreError > ,
516+ T3 :: Error : From < CryptoCoreError > ,
517+ T4 :: Error : From < CryptoCoreError > ,
518+ {
519+ type Error = CryptoCoreError ;
520+
521+ fn length ( & self ) -> usize {
522+ self . 0 . length ( ) + self . 1 . length ( ) + self . 1 . length ( ) + self . 3 . length ( )
523+ }
524+
525+ fn write ( & self , ser : & mut Serializer ) -> Result < usize , Self :: Error > {
526+ Ok ( self
527+ . 0
458528 . write ( ser)
459- . map_err ( |e| Self :: Error :: GenericSerializationError ( e. to_string ( ) ) ) ?;
460- Ok ( n)
529+ . map_err ( |e| Self :: Error :: GenericSerializationError ( e. to_string ( ) ) ) ?
530+ + self
531+ . 1
532+ . write ( ser)
533+ . map_err ( |e| Self :: Error :: GenericSerializationError ( e. to_string ( ) ) ) ?
534+ + self
535+ . 2
536+ . write ( ser)
537+ . map_err ( |e| Self :: Error :: GenericSerializationError ( e. to_string ( ) ) ) ?
538+ + self
539+ . 3
540+ . write ( ser)
541+ . map_err ( |e| Self :: Error :: GenericSerializationError ( e. to_string ( ) ) ) ?)
461542 }
462543
463544 fn read ( de : & mut Deserializer ) -> Result < Self , Self :: Error > {
@@ -466,6 +547,10 @@ where
466547 . map_err ( |e : T1 :: Error | Self :: Error :: GenericDeserializationError ( e. to_string ( ) ) ) ?,
467548 de. read ( )
468549 . map_err ( |e : T2 :: Error | Self :: Error :: GenericDeserializationError ( e. to_string ( ) ) ) ?,
550+ de. read ( )
551+ . map_err ( |e : T3 :: Error | Self :: Error :: GenericDeserializationError ( e. to_string ( ) ) ) ?,
552+ de. read ( )
553+ . map_err ( |e : T4 :: Error | Self :: Error :: GenericDeserializationError ( e. to_string ( ) ) ) ?,
469554 ) )
470555 }
471556}
0 commit comments