@@ -62,47 +62,47 @@ fn guest_function(function_call: &FunctionCall) -> Result<Vec<u8>> {
62
62
if let ParameterValue :: String ( message) = & function_call. parameters . as_ref ( ) . unwrap ( ) [ 0 ] {
63
63
send_message_to_host_method ( "HostMethod" , "Hello from GuestFunction, " , message)
64
64
} else {
65
- return Err ( HyperlightGuestError :: new (
65
+ Err ( HyperlightGuestError :: new (
66
66
ErrorCode :: GuestFunctionParameterTypeMismatch ,
67
67
"Invalid parameters passed to guest_function" . to_string ( ) ,
68
- ) ) ;
68
+ ) )
69
69
}
70
70
}
71
71
72
72
fn guest_function1 ( function_call : & FunctionCall ) -> Result < Vec < u8 > > {
73
73
if let ParameterValue :: String ( message) = & function_call. parameters . as_ref ( ) . unwrap ( ) [ 0 ] {
74
74
send_message_to_host_method ( "HostMethod1" , "Hello from GuestFunction1, " , message)
75
75
} else {
76
- return Err ( HyperlightGuestError :: new (
76
+ Err ( HyperlightGuestError :: new (
77
77
ErrorCode :: GuestFunctionParameterTypeMismatch ,
78
78
"Invalid parameters passed to guest_function1" . to_string ( ) ,
79
- ) ) ;
79
+ ) )
80
80
}
81
81
}
82
82
83
83
fn guest_function2 ( function_call : & FunctionCall ) -> Result < Vec < u8 > > {
84
84
if let ParameterValue :: String ( message) = & function_call. parameters . as_ref ( ) . unwrap ( ) [ 0 ] {
85
85
send_message_to_host_method ( "HostMethod1" , "Hello from GuestFunction2, " , message)
86
86
} else {
87
- return Err ( HyperlightGuestError :: new (
87
+ Err ( HyperlightGuestError :: new (
88
88
ErrorCode :: GuestFunctionParameterTypeMismatch ,
89
89
"Invalid parameters passed to guest_function2" . to_string ( ) ,
90
- ) ) ;
90
+ ) )
91
91
}
92
92
}
93
93
94
94
fn guest_function3 ( function_call : & FunctionCall ) -> Result < Vec < u8 > > {
95
95
if let ParameterValue :: String ( message) = & function_call. parameters . as_ref ( ) . unwrap ( ) [ 0 ] {
96
96
send_message_to_host_method ( "HostMethod1" , "Hello from GuestFunction3, " , message)
97
97
} else {
98
- return Err ( HyperlightGuestError :: new (
98
+ Err ( HyperlightGuestError :: new (
99
99
ErrorCode :: GuestFunctionParameterTypeMismatch ,
100
100
"Invalid parameters passed to guest_function3" . to_string ( ) ,
101
- ) ) ;
101
+ ) )
102
102
}
103
103
}
104
104
105
- fn guest_function4 ( ) -> Result < Vec < u8 > > {
105
+ fn guest_function4 ( _ : & FunctionCall ) -> Result < Vec < u8 > > {
106
106
call_host_function (
107
107
"HostMethod4" ,
108
108
Some ( Vec :: from ( & [ ParameterValue :: String (
@@ -125,7 +125,7 @@ fn guest_log_message(function_call: &FunctionCall) -> Result<Vec<u8>> {
125
125
& function_call. parameters . as_ref ( ) . unwrap ( ) [ 2 ] ,
126
126
) {
127
127
let mut log_level = * level;
128
- if log_level < 0 || log_level > 6 {
128
+ if ! ( 0 ..= 6 ) . contains ( & log_level ) {
129
129
log_level = 0 ;
130
130
}
131
131
@@ -140,25 +140,25 @@ fn guest_log_message(function_call: &FunctionCall) -> Result<Vec<u8>> {
140
140
141
141
Ok ( get_flatbuffer_result_from_int ( message. len ( ) as i32 ) )
142
142
} else {
143
- return Err ( HyperlightGuestError :: new (
143
+ Err ( HyperlightGuestError :: new (
144
144
ErrorCode :: GuestFunctionParameterTypeMismatch ,
145
145
"Invalid parameters passed to guest_log_message" . to_string ( ) ,
146
- ) ) ;
146
+ ) )
147
147
}
148
148
}
149
149
150
150
fn call_error_method ( function_call : & FunctionCall ) -> Result < Vec < u8 > > {
151
151
if let ParameterValue :: String ( message) = & function_call. parameters . as_ref ( ) . unwrap ( ) [ 0 ] {
152
152
send_message_to_host_method ( "ErrorMethod" , "Error From Host: " , message)
153
153
} else {
154
- return Err ( HyperlightGuestError :: new (
154
+ Err ( HyperlightGuestError :: new (
155
155
ErrorCode :: GuestFunctionParameterTypeMismatch ,
156
156
"Invalid parameters passed to call_error_method" . to_string ( ) ,
157
- ) ) ;
157
+ ) )
158
158
}
159
159
}
160
160
161
- fn call_host_spin ( ) -> Result < Vec < u8 > > {
161
+ fn call_host_spin ( _ : & FunctionCall ) -> Result < Vec < u8 > > {
162
162
call_host_function ( "Spin" , None , ReturnType :: Void ) ?;
163
163
Ok ( get_flatbuffer_result_from_void ( ) )
164
164
}
@@ -169,47 +169,47 @@ pub extern "C" fn hyperlight_main() {
169
169
"PrintOutput" . to_string ( ) ,
170
170
Vec :: from ( & [ ParameterType :: String ] ) ,
171
171
ReturnType :: Int ,
172
- print_output_as_guest_function as i64 ,
172
+ print_output_as_guest_function as usize ,
173
173
) ;
174
174
register_function ( print_output_def) ;
175
175
176
176
let guest_function_def = GuestFunctionDefinition :: new (
177
177
"GuestMethod" . to_string ( ) ,
178
178
Vec :: from ( & [ ParameterType :: String ] ) ,
179
179
ReturnType :: Int ,
180
- guest_function as i64 ,
180
+ guest_function as usize ,
181
181
) ;
182
182
register_function ( guest_function_def) ;
183
183
184
184
let guest_function1_def = GuestFunctionDefinition :: new (
185
185
"GuestMethod1" . to_string ( ) ,
186
186
Vec :: from ( & [ ParameterType :: String ] ) ,
187
187
ReturnType :: Int ,
188
- guest_function1 as i64 ,
188
+ guest_function1 as usize ,
189
189
) ;
190
190
register_function ( guest_function1_def) ;
191
191
192
192
let guest_function2_def = GuestFunctionDefinition :: new (
193
193
"GuestMethod2" . to_string ( ) ,
194
194
Vec :: from ( & [ ParameterType :: String ] ) ,
195
195
ReturnType :: Int ,
196
- guest_function2 as i64 ,
196
+ guest_function2 as usize ,
197
197
) ;
198
198
register_function ( guest_function2_def) ;
199
199
200
200
let guest_function3_def = GuestFunctionDefinition :: new (
201
201
"GuestMethod3" . to_string ( ) ,
202
202
Vec :: from ( & [ ParameterType :: String ] ) ,
203
203
ReturnType :: Int ,
204
- guest_function3 as i64 ,
204
+ guest_function3 as usize ,
205
205
) ;
206
206
register_function ( guest_function3_def) ;
207
207
208
208
let guest_function4_def = GuestFunctionDefinition :: new (
209
209
"GuestMethod4" . to_string ( ) ,
210
210
Vec :: new ( ) ,
211
211
ReturnType :: Int ,
212
- guest_function4 as i64 ,
212
+ guest_function4 as usize ,
213
213
) ;
214
214
register_function ( guest_function4_def) ;
215
215
@@ -221,23 +221,23 @@ pub extern "C" fn hyperlight_main() {
221
221
ParameterType :: Int ,
222
222
] ) ,
223
223
ReturnType :: Int ,
224
- guest_log_message as i64 ,
224
+ guest_log_message as usize ,
225
225
) ;
226
226
register_function ( guest_log_message_def) ;
227
227
228
228
let call_error_method_def = GuestFunctionDefinition :: new (
229
229
"CallErrorMethod" . to_string ( ) ,
230
230
Vec :: from ( & [ ParameterType :: String ] ) ,
231
231
ReturnType :: Int ,
232
- call_error_method as i64 ,
232
+ call_error_method as usize ,
233
233
) ;
234
234
register_function ( call_error_method_def) ;
235
235
236
236
let call_host_spin_def = GuestFunctionDefinition :: new (
237
237
"CallHostSpin" . to_string ( ) ,
238
238
Vec :: new ( ) ,
239
239
ReturnType :: Int ,
240
- call_host_spin as i64 ,
240
+ call_host_spin as usize ,
241
241
) ;
242
242
register_function ( call_host_spin_def) ;
243
243
}
0 commit comments