@@ -61,12 +61,36 @@ impl Default for anon_0 {
6161 }
6262 }
6363}
64- impl ByteRepr for anon_0 { }
64+ impl ByteRepr for anon_0 {
65+ fn byte_size ( ) -> usize {
66+ 128
67+ }
68+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
69+ buf. copy_from_slice ( & self . __bytes . borrow ( ) ) ;
70+ }
71+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
72+ anon_0 {
73+ __bytes : Rc :: new ( RefCell :: new ( Box :: from ( buf) ) ) ,
74+ }
75+ }
76+ }
6577#[ derive( Default ) ]
6678pub struct inner {
6779 pub view : Value < anon_0 > ,
6880}
69- impl ByteRepr for inner { }
81+ impl ByteRepr for inner {
82+ fn byte_size ( ) -> usize {
83+ 128
84+ }
85+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
86+ ( * self . view . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..128 ] ) ;
87+ }
88+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
89+ Self {
90+ view : Rc :: new ( RefCell :: new ( <anon_0 >:: from_bytes ( & buf[ 0 ..128 ] ) ) ) ,
91+ }
92+ }
93+ }
7094pub struct anon_1 {
7195 __bytes : Value < Box < [ u8 ] > > ,
7296}
@@ -92,7 +116,19 @@ impl Default for anon_1 {
92116 }
93117 }
94118}
95- impl ByteRepr for anon_1 { }
119+ impl ByteRepr for anon_1 {
120+ fn byte_size ( ) -> usize {
121+ 128
122+ }
123+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
124+ buf. copy_from_slice ( & self . __bytes . borrow ( ) ) ;
125+ }
126+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
127+ anon_1 {
128+ __bytes : Rc :: new ( RefCell :: new ( Box :: from ( buf) ) ) ,
129+ }
130+ }
131+ }
96132#[ derive( Default ) ]
97133pub struct Outer {
98134 pub kind : Value < i32 > ,
@@ -101,7 +137,27 @@ pub struct Outer {
101137 pub len : Value < u32 > ,
102138 pub body : Value < anon_1 > ,
103139}
104- impl ByteRepr for Outer { }
140+ impl ByteRepr for Outer {
141+ fn byte_size ( ) -> usize {
142+ 144
143+ }
144+ fn to_bytes ( & self , buf : & mut [ u8 ] ) {
145+ ( * self . kind . borrow ( ) ) . to_bytes ( & mut buf[ 0 ..4 ] ) ;
146+ ( * self . level . borrow ( ) ) . to_bytes ( & mut buf[ 4 ..8 ] ) ;
147+ ( * self . variant . borrow ( ) ) . to_bytes ( & mut buf[ 8 ..12 ] ) ;
148+ ( * self . len . borrow ( ) ) . to_bytes ( & mut buf[ 12 ..16 ] ) ;
149+ ( * self . body . borrow ( ) ) . to_bytes ( & mut buf[ 16 ..144 ] ) ;
150+ }
151+ fn from_bytes ( buf : & [ u8 ] ) -> Self {
152+ Self {
153+ kind : Rc :: new ( RefCell :: new ( <i32 >:: from_bytes ( & buf[ 0 ..4 ] ) ) ) ,
154+ level : Rc :: new ( RefCell :: new ( <i32 >:: from_bytes ( & buf[ 4 ..8 ] ) ) ) ,
155+ variant : Rc :: new ( RefCell :: new ( <i32 >:: from_bytes ( & buf[ 8 ..12 ] ) ) ) ,
156+ len : Rc :: new ( RefCell :: new ( <u32 >:: from_bytes ( & buf[ 12 ..16 ] ) ) ) ,
157+ body : Rc :: new ( RefCell :: new ( <anon_1 >:: from_bytes ( & buf[ 16 ..144 ] ) ) ) ,
158+ }
159+ }
160+ }
105161pub fn main ( ) {
106162 std:: process:: exit ( main_0 ( ) ) ;
107163}
0 commit comments