@@ -60,47 +60,47 @@ fn guest_function(function_call: &FunctionCall) -> Result<Vec<u8>> {
6060 if let ParameterValue :: String ( message) = & function_call. parameters . as_ref ( ) . unwrap ( ) [ 0 ] {
6161 send_message_to_host_method ( "HostMethod" , "Hello from GuestFunction, " , message)
6262 } else {
63- return Err ( HyperlightGuestError :: new (
63+ Err ( HyperlightGuestError :: new (
6464 ErrorCode :: GuestFunctionParameterTypeMismatch ,
6565 "Invalid parameters passed to guest_function" . to_string ( ) ,
66- ) ) ;
66+ ) )
6767 }
6868}
6969
7070fn guest_function1 ( function_call : & FunctionCall ) -> Result < Vec < u8 > > {
7171 if let ParameterValue :: String ( message) = & function_call. parameters . as_ref ( ) . unwrap ( ) [ 0 ] {
7272 send_message_to_host_method ( "HostMethod1" , "Hello from GuestFunction1, " , message)
7373 } else {
74- return Err ( HyperlightGuestError :: new (
74+ Err ( HyperlightGuestError :: new (
7575 ErrorCode :: GuestFunctionParameterTypeMismatch ,
7676 "Invalid parameters passed to guest_function1" . to_string ( ) ,
77- ) ) ;
77+ ) )
7878 }
7979}
8080
8181fn guest_function2 ( function_call : & FunctionCall ) -> Result < Vec < u8 > > {
8282 if let ParameterValue :: String ( message) = & function_call. parameters . as_ref ( ) . unwrap ( ) [ 0 ] {
8383 send_message_to_host_method ( "HostMethod1" , "Hello from GuestFunction2, " , message)
8484 } else {
85- return Err ( HyperlightGuestError :: new (
85+ Err ( HyperlightGuestError :: new (
8686 ErrorCode :: GuestFunctionParameterTypeMismatch ,
8787 "Invalid parameters passed to guest_function2" . to_string ( ) ,
88- ) ) ;
88+ ) )
8989 }
9090}
9191
9292fn guest_function3 ( function_call : & FunctionCall ) -> Result < Vec < u8 > > {
9393 if let ParameterValue :: String ( message) = & function_call. parameters . as_ref ( ) . unwrap ( ) [ 0 ] {
9494 send_message_to_host_method ( "HostMethod1" , "Hello from GuestFunction3, " , message)
9595 } else {
96- return Err ( HyperlightGuestError :: new (
96+ Err ( HyperlightGuestError :: new (
9797 ErrorCode :: GuestFunctionParameterTypeMismatch ,
9898 "Invalid parameters passed to guest_function3" . to_string ( ) ,
99- ) ) ;
99+ ) )
100100 }
101101}
102102
103- fn guest_function4 ( ) -> Result < Vec < u8 > > {
103+ fn guest_function4 ( _ : & FunctionCall ) -> Result < Vec < u8 > > {
104104 call_host_function (
105105 "HostMethod4" ,
106106 Some ( Vec :: from ( & [ ParameterValue :: String (
@@ -123,7 +123,7 @@ fn guest_log_message(function_call: &FunctionCall) -> Result<Vec<u8>> {
123123 & function_call. parameters . as_ref ( ) . unwrap ( ) [ 2 ] ,
124124 ) {
125125 let mut log_level = * level;
126- if log_level < 0 || log_level > 6 {
126+ if ! ( 0 ..= 6 ) . contains ( & log_level ) {
127127 log_level = 0 ;
128128 }
129129
@@ -138,25 +138,25 @@ fn guest_log_message(function_call: &FunctionCall) -> Result<Vec<u8>> {
138138
139139 Ok ( get_flatbuffer_result ( message. len ( ) as i32 ) )
140140 } else {
141- return Err ( HyperlightGuestError :: new (
141+ Err ( HyperlightGuestError :: new (
142142 ErrorCode :: GuestFunctionParameterTypeMismatch ,
143143 "Invalid parameters passed to guest_log_message" . to_string ( ) ,
144- ) ) ;
144+ ) )
145145 }
146146}
147147
148148fn call_error_method ( function_call : & FunctionCall ) -> Result < Vec < u8 > > {
149149 if let ParameterValue :: String ( message) = & function_call. parameters . as_ref ( ) . unwrap ( ) [ 0 ] {
150150 send_message_to_host_method ( "ErrorMethod" , "Error From Host: " , message)
151151 } else {
152- return Err ( HyperlightGuestError :: new (
152+ Err ( HyperlightGuestError :: new (
153153 ErrorCode :: GuestFunctionParameterTypeMismatch ,
154154 "Invalid parameters passed to call_error_method" . to_string ( ) ,
155- ) ) ;
155+ ) )
156156 }
157157}
158158
159- fn call_host_spin ( ) -> Result < Vec < u8 > > {
159+ fn call_host_spin ( _ : & FunctionCall ) -> Result < Vec < u8 > > {
160160 call_host_function ( "Spin" , None , ReturnType :: Void ) ?;
161161 Ok ( get_flatbuffer_result ( ( ) ) )
162162}
@@ -167,47 +167,47 @@ pub extern "C" fn hyperlight_main() {
167167 "PrintOutput" . to_string ( ) ,
168168 Vec :: from ( & [ ParameterType :: String ] ) ,
169169 ReturnType :: Int ,
170- print_output_as_guest_function as i64 ,
170+ print_output_as_guest_function as usize ,
171171 ) ;
172172 register_function ( print_output_def) ;
173173
174174 let guest_function_def = GuestFunctionDefinition :: new (
175175 "GuestMethod" . to_string ( ) ,
176176 Vec :: from ( & [ ParameterType :: String ] ) ,
177177 ReturnType :: Int ,
178- guest_function as i64 ,
178+ guest_function as usize ,
179179 ) ;
180180 register_function ( guest_function_def) ;
181181
182182 let guest_function1_def = GuestFunctionDefinition :: new (
183183 "GuestMethod1" . to_string ( ) ,
184184 Vec :: from ( & [ ParameterType :: String ] ) ,
185185 ReturnType :: Int ,
186- guest_function1 as i64 ,
186+ guest_function1 as usize ,
187187 ) ;
188188 register_function ( guest_function1_def) ;
189189
190190 let guest_function2_def = GuestFunctionDefinition :: new (
191191 "GuestMethod2" . to_string ( ) ,
192192 Vec :: from ( & [ ParameterType :: String ] ) ,
193193 ReturnType :: Int ,
194- guest_function2 as i64 ,
194+ guest_function2 as usize ,
195195 ) ;
196196 register_function ( guest_function2_def) ;
197197
198198 let guest_function3_def = GuestFunctionDefinition :: new (
199199 "GuestMethod3" . to_string ( ) ,
200200 Vec :: from ( & [ ParameterType :: String ] ) ,
201201 ReturnType :: Int ,
202- guest_function3 as i64 ,
202+ guest_function3 as usize ,
203203 ) ;
204204 register_function ( guest_function3_def) ;
205205
206206 let guest_function4_def = GuestFunctionDefinition :: new (
207207 "GuestMethod4" . to_string ( ) ,
208208 Vec :: new ( ) ,
209209 ReturnType :: Int ,
210- guest_function4 as i64 ,
210+ guest_function4 as usize ,
211211 ) ;
212212 register_function ( guest_function4_def) ;
213213
@@ -219,23 +219,23 @@ pub extern "C" fn hyperlight_main() {
219219 ParameterType :: Int ,
220220 ] ) ,
221221 ReturnType :: Int ,
222- guest_log_message as i64 ,
222+ guest_log_message as usize ,
223223 ) ;
224224 register_function ( guest_log_message_def) ;
225225
226226 let call_error_method_def = GuestFunctionDefinition :: new (
227227 "CallErrorMethod" . to_string ( ) ,
228228 Vec :: from ( & [ ParameterType :: String ] ) ,
229229 ReturnType :: Int ,
230- call_error_method as i64 ,
230+ call_error_method as usize ,
231231 ) ;
232232 register_function ( call_error_method_def) ;
233233
234234 let call_host_spin_def = GuestFunctionDefinition :: new (
235235 "CallHostSpin" . to_string ( ) ,
236236 Vec :: new ( ) ,
237237 ReturnType :: Int ,
238- call_host_spin as i64 ,
238+ call_host_spin as usize ,
239239 ) ;
240240 register_function ( call_host_spin_def) ;
241241}
0 commit comments