@@ -62,47 +62,47 @@ fn guest_function(function_call: &FunctionCall) -> Result<Vec<u8>> {
6262 if let ParameterValue :: String ( message) = & function_call. parameters . as_ref ( ) . unwrap ( ) [ 0 ] {
6363 send_message_to_host_method ( "HostMethod" , "Hello from GuestFunction, " , message)
6464 } else {
65- return Err ( HyperlightGuestError :: new (
65+ Err ( HyperlightGuestError :: new (
6666 ErrorCode :: GuestFunctionParameterTypeMismatch ,
6767 "Invalid parameters passed to guest_function" . to_string ( ) ,
68- ) ) ;
68+ ) )
6969 }
7070}
7171
7272fn guest_function1 ( function_call : & FunctionCall ) -> Result < Vec < u8 > > {
7373 if let ParameterValue :: String ( message) = & function_call. parameters . as_ref ( ) . unwrap ( ) [ 0 ] {
7474 send_message_to_host_method ( "HostMethod1" , "Hello from GuestFunction1, " , message)
7575 } else {
76- return Err ( HyperlightGuestError :: new (
76+ Err ( HyperlightGuestError :: new (
7777 ErrorCode :: GuestFunctionParameterTypeMismatch ,
7878 "Invalid parameters passed to guest_function1" . to_string ( ) ,
79- ) ) ;
79+ ) )
8080 }
8181}
8282
8383fn guest_function2 ( function_call : & FunctionCall ) -> Result < Vec < u8 > > {
8484 if let ParameterValue :: String ( message) = & function_call. parameters . as_ref ( ) . unwrap ( ) [ 0 ] {
8585 send_message_to_host_method ( "HostMethod1" , "Hello from GuestFunction2, " , message)
8686 } else {
87- return Err ( HyperlightGuestError :: new (
87+ Err ( HyperlightGuestError :: new (
8888 ErrorCode :: GuestFunctionParameterTypeMismatch ,
8989 "Invalid parameters passed to guest_function2" . to_string ( ) ,
90- ) ) ;
90+ ) )
9191 }
9292}
9393
9494fn guest_function3 ( function_call : & FunctionCall ) -> Result < Vec < u8 > > {
9595 if let ParameterValue :: String ( message) = & function_call. parameters . as_ref ( ) . unwrap ( ) [ 0 ] {
9696 send_message_to_host_method ( "HostMethod1" , "Hello from GuestFunction3, " , message)
9797 } else {
98- return Err ( HyperlightGuestError :: new (
98+ Err ( HyperlightGuestError :: new (
9999 ErrorCode :: GuestFunctionParameterTypeMismatch ,
100100 "Invalid parameters passed to guest_function3" . to_string ( ) ,
101- ) ) ;
101+ ) )
102102 }
103103}
104104
105- fn guest_function4 ( ) -> Result < Vec < u8 > > {
105+ fn guest_function4 ( _ : & FunctionCall ) -> Result < Vec < u8 > > {
106106 call_host_function (
107107 "HostMethod4" ,
108108 Some ( Vec :: from ( & [ ParameterValue :: String (
@@ -125,7 +125,7 @@ fn guest_log_message(function_call: &FunctionCall) -> Result<Vec<u8>> {
125125 & function_call. parameters . as_ref ( ) . unwrap ( ) [ 2 ] ,
126126 ) {
127127 let mut log_level = * level;
128- if log_level < 0 || log_level > 6 {
128+ if ! ( 0 ..= 6 ) . contains ( & log_level ) {
129129 log_level = 0 ;
130130 }
131131
@@ -140,25 +140,25 @@ fn guest_log_message(function_call: &FunctionCall) -> Result<Vec<u8>> {
140140
141141 Ok ( get_flatbuffer_result_from_int ( message. len ( ) as i32 ) )
142142 } else {
143- return Err ( HyperlightGuestError :: new (
143+ Err ( HyperlightGuestError :: new (
144144 ErrorCode :: GuestFunctionParameterTypeMismatch ,
145145 "Invalid parameters passed to guest_log_message" . to_string ( ) ,
146- ) ) ;
146+ ) )
147147 }
148148}
149149
150150fn call_error_method ( function_call : & FunctionCall ) -> Result < Vec < u8 > > {
151151 if let ParameterValue :: String ( message) = & function_call. parameters . as_ref ( ) . unwrap ( ) [ 0 ] {
152152 send_message_to_host_method ( "ErrorMethod" , "Error From Host: " , message)
153153 } else {
154- return Err ( HyperlightGuestError :: new (
154+ Err ( HyperlightGuestError :: new (
155155 ErrorCode :: GuestFunctionParameterTypeMismatch ,
156156 "Invalid parameters passed to call_error_method" . to_string ( ) ,
157- ) ) ;
157+ ) )
158158 }
159159}
160160
161- fn call_host_spin ( ) -> Result < Vec < u8 > > {
161+ fn call_host_spin ( _ : & FunctionCall ) -> Result < Vec < u8 > > {
162162 call_host_function ( "Spin" , None , ReturnType :: Void ) ?;
163163 Ok ( get_flatbuffer_result_from_void ( ) )
164164}
@@ -169,47 +169,47 @@ pub extern "C" fn hyperlight_main() {
169169 "PrintOutput" . to_string ( ) ,
170170 Vec :: from ( & [ ParameterType :: String ] ) ,
171171 ReturnType :: Int ,
172- print_output_as_guest_function as i64 ,
172+ print_output_as_guest_function as usize ,
173173 ) ;
174174 register_function ( print_output_def) ;
175175
176176 let guest_function_def = GuestFunctionDefinition :: new (
177177 "GuestMethod" . to_string ( ) ,
178178 Vec :: from ( & [ ParameterType :: String ] ) ,
179179 ReturnType :: Int ,
180- guest_function as i64 ,
180+ guest_function as usize ,
181181 ) ;
182182 register_function ( guest_function_def) ;
183183
184184 let guest_function1_def = GuestFunctionDefinition :: new (
185185 "GuestMethod1" . to_string ( ) ,
186186 Vec :: from ( & [ ParameterType :: String ] ) ,
187187 ReturnType :: Int ,
188- guest_function1 as i64 ,
188+ guest_function1 as usize ,
189189 ) ;
190190 register_function ( guest_function1_def) ;
191191
192192 let guest_function2_def = GuestFunctionDefinition :: new (
193193 "GuestMethod2" . to_string ( ) ,
194194 Vec :: from ( & [ ParameterType :: String ] ) ,
195195 ReturnType :: Int ,
196- guest_function2 as i64 ,
196+ guest_function2 as usize ,
197197 ) ;
198198 register_function ( guest_function2_def) ;
199199
200200 let guest_function3_def = GuestFunctionDefinition :: new (
201201 "GuestMethod3" . to_string ( ) ,
202202 Vec :: from ( & [ ParameterType :: String ] ) ,
203203 ReturnType :: Int ,
204- guest_function3 as i64 ,
204+ guest_function3 as usize ,
205205 ) ;
206206 register_function ( guest_function3_def) ;
207207
208208 let guest_function4_def = GuestFunctionDefinition :: new (
209209 "GuestMethod4" . to_string ( ) ,
210210 Vec :: new ( ) ,
211211 ReturnType :: Int ,
212- guest_function4 as i64 ,
212+ guest_function4 as usize ,
213213 ) ;
214214 register_function ( guest_function4_def) ;
215215
@@ -221,23 +221,23 @@ pub extern "C" fn hyperlight_main() {
221221 ParameterType :: Int ,
222222 ] ) ,
223223 ReturnType :: Int ,
224- guest_log_message as i64 ,
224+ guest_log_message as usize ,
225225 ) ;
226226 register_function ( guest_log_message_def) ;
227227
228228 let call_error_method_def = GuestFunctionDefinition :: new (
229229 "CallErrorMethod" . to_string ( ) ,
230230 Vec :: from ( & [ ParameterType :: String ] ) ,
231231 ReturnType :: Int ,
232- call_error_method as i64 ,
232+ call_error_method as usize ,
233233 ) ;
234234 register_function ( call_error_method_def) ;
235235
236236 let call_host_spin_def = GuestFunctionDefinition :: new (
237237 "CallHostSpin" . to_string ( ) ,
238238 Vec :: new ( ) ,
239239 ReturnType :: Int ,
240- call_host_spin as i64 ,
240+ call_host_spin as usize ,
241241 ) ;
242242 register_function ( call_host_spin_def) ;
243243}
0 commit comments