@@ -122,12 +122,12 @@ impl RustGenerator {
122122
123123 let value = $type_ident:: default ( ) ;
124124
125- let bytes = value. serialize ( ) . expect( "serialize " ) ;
125+ let bytes = value. to_payload ( ) . expect( "to_payload " ) ;
126126
127127 let hex: String = bytes. iter( ) . map( |b| format!( "{:02X}" , b) ) . collect( ) ;
128128 println!( "HEX: 0x{}" , hex) ;
129129
130- let decoded = $type_ident_clone:: deserialize ( & bytes) . expect( "deserialize " ) ;
130+ let decoded = $type_ident_clone:: from_payload ( & bytes) . expect( "from_payload " ) ;
131131
132132 assert_eq!( value, decoded) ;
133133 println!( "{:?}" , decoded) ;
@@ -159,20 +159,20 @@ impl RustGenerator {
159159 }
160160
161161 pub trait BinarySerializable : Sized {
162- fn serialize ( & self ) -> Result <Vec <u8 >, Error > {
162+ fn to_payload ( & self ) -> Result <Vec <u8 >, Error > {
163163 let mut buf = Vec :: new( ) ;
164- self . write_into ( & mut buf) ?;
164+ self . write_payload ( & mut buf) ?;
165165 Ok ( buf)
166166 }
167167
168- fn write_into ( & self , buf: & mut Vec <u8 >) -> Result <( ) , Error >;
168+ fn write_payload ( & self , buf: & mut Vec <u8 >) -> Result <( ) , Error >;
169169
170- fn deserialize ( bytes: & [ u8 ] ) -> Result <Self , Error > {
170+ fn from_payload ( bytes: & [ u8 ] ) -> Result <Self , Error > {
171171 let mut cursor = Cursor :: new( bytes) ;
172- Self :: read_from ( & mut cursor)
172+ Self :: read_payload ( & mut cursor)
173173 }
174174
175- fn read_from ( cursor: & mut Cursor <& [ u8 ] >) -> Result <Self , Error >;
175+ fn read_payload ( cursor: & mut Cursor <& [ u8 ] >) -> Result <Self , Error >;
176176 }
177177
178178 pub fn write_bool( buf: & mut Vec <u8 >, value: bool ) {
@@ -541,12 +541,12 @@ impl RustGenerator {
541541 }
542542
543543 impl runtime:: BinarySerializable for $ident {
544- fn write_into ( & self , buf: & mut Vec <u8 >) -> Result <( ) , runtime:: Error > {
544+ fn write_payload ( & self , buf: & mut Vec <u8 >) -> Result <( ) , runtime:: Error > {
545545 $( for w in writes => $w)
546546 Ok ( ( ) )
547547 }
548548
549- fn read_from ( cursor: & mut std:: io:: Cursor <& [ u8 ] >) -> Result <Self , runtime:: Error > {
549+ fn read_payload ( cursor: & mut std:: io:: Cursor <& [ u8 ] >) -> Result <Self , runtime:: Error > {
550550 $( for r in reads => $r)
551551 Ok ( Self { $( for n in field_names => $n) } )
552552 }
@@ -608,7 +608,7 @@ impl RustGenerator {
608608 let writer = self . writer_fn ( base_type) ;
609609 quote ! ( runtime:: $writer( buf, ( * $expr) . into( ) ) ; )
610610 } else {
611- quote ! ( runtime:: BinarySerializable :: write_into ( $expr, buf) ?; )
611+ quote ! ( runtime:: BinarySerializable :: write_payload ( $expr, buf) ?; )
612612 }
613613 }
614614 _ => quote ! {
@@ -651,7 +651,7 @@ impl RustGenerator {
651651 } }
652652 } else {
653653 let path_tokens = self . relative_path ( path, scope) ;
654- quote ! ( <$path_tokens as runtime:: BinarySerializable >:: read_from ( cursor) )
654+ quote ! ( <$path_tokens as runtime:: BinarySerializable >:: read_payload ( cursor) )
655655 }
656656 }
657657 _ => quote ! {
0 commit comments