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