@@ -38,6 +38,9 @@ pub struct widget {
3838 pub mode : Value < widget_enum > ,
3939}
4040impl ByteRepr for widget {
41+ fn byte_size ( ) -> usize {
42+ 8
43+ }
4144 fn to_bytes ( & self , buf : & mut [ u8 ] ) {
4245 ( * self . id . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..4 ] ) ;
4346 ( * self . mode . borrow ( ) ) . to_bytes ( & mut buf[ 4 ..8 ] ) ;
@@ -55,6 +58,9 @@ pub struct point_struct {
5558 pub y : Value < i32 > ,
5659}
5760impl ByteRepr for point_struct {
61+ fn byte_size ( ) -> usize {
62+ 8
63+ }
5864 fn to_bytes ( & self , buf : & mut [ u8 ] ) {
5965 ( * self . x . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..4 ] ) ;
6066 ( * self . y . borrow ( ) ) . to_bytes ( & mut buf[ 4 ..8 ] ) ;
@@ -147,6 +153,9 @@ pub struct Inner {
147153 pub tag_field : Value < i32 > ,
148154}
149155impl ByteRepr for Inner {
156+ fn byte_size ( ) -> usize {
157+ 4
158+ }
150159 fn to_bytes ( & self , buf : & mut [ u8 ] ) {
151160 ( * self . tag_field . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..4 ] ) ;
152161 }
@@ -160,12 +169,27 @@ impl ByteRepr for Inner {
160169pub struct Outer {
161170 pub field : Value < Inner > ,
162171}
163- impl ByteRepr for Outer { }
172+ impl ByteRepr for Outer {
173+ fn byte_size ( ) -> usize {
174+ 4
175+ }
176+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
177+ ( * self . field . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..4 ] ) ;
178+ }
179+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
180+ Self {
181+ field : Rc :: new ( RefCell :: new ( <Inner >:: from_bytes ( & buf[ 0 ..4 ] ) ) ) ,
182+ }
183+ }
184+ }
164185#[ derive( Default ) ]
165186pub struct Inner_struct {
166187 pub typedef_field : Value < i32 > ,
167188}
168189impl ByteRepr for Inner_struct {
190+ fn byte_size ( ) -> usize {
191+ 4
192+ }
169193 fn to_bytes ( & self , buf : & mut [ u8 ] ) {
170194 ( * self . typedef_field . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..4 ] ) ;
171195 }
0 commit comments