@@ -14,8 +14,7 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- use hyperlight_host:: func:: call_ctx:: MultiUseGuestCallContext ;
18- use hyperlight_host:: sandbox:: { Callable , MultiUseSandbox , UninitializedSandbox } ;
17+ use hyperlight_host:: sandbox:: { MultiUseSandbox , UninitializedSandbox } ;
1918use hyperlight_host:: sandbox_state:: sandbox:: EvolvableSandbox ;
2019use hyperlight_host:: sandbox_state:: transition:: Noop ;
2120use hyperlight_host:: { GuestBinary , Result } ;
@@ -24,32 +23,32 @@ use hyperlight_testing::simple_guest_as_string;
2423fn main ( ) {
2524 // create a new `MultiUseSandbox` configured to run the `simpleguest.exe`
2625 // test guest binary
27- let sbox1: MultiUseSandbox = {
26+ let mut sbox1: MultiUseSandbox = {
2827 let path = simple_guest_as_string ( ) . unwrap ( ) ;
2928 let u_sbox = UninitializedSandbox :: new ( GuestBinary :: FilePath ( path) , None ) . unwrap ( ) ;
3029 u_sbox. evolve ( Noop :: default ( ) )
3130 }
3231 . unwrap ( ) ;
3332
3433 // create a new call context from the sandbox, then do some calls with it.
35- let ctx1 = sbox1. new_call_context ( ) ;
36- let sbox2 = do_calls ( ctx1 ) . unwrap ( ) ;
34+ do_calls ( & mut sbox1) . unwrap ( ) ;
35+
3736 // create a new call context from the returned sandbox, then do some calls
3837 // with that one
39- let ctx2 = sbox2. new_call_context ( ) ;
40- do_calls ( ctx2) . unwrap ( ) ;
38+ do_calls ( & mut sbox1) . unwrap ( ) ;
4139}
4240
4341/// Given a `MultiUseGuestCallContext` derived from an existing
4442/// `MultiUseSandbox` configured to run the `simpleguest.exe` test guest
4543/// binary, do several calls against that binary, print their results, then
4644/// call `ctx.finish()` and return the resulting `MultiUseSandbox`. Return an `Err`
4745/// if anything failed.
48- fn do_calls ( mut ctx : MultiUseGuestCallContext ) -> Result < MultiUseSandbox > {
49- let res: String = ctx . call ( "Echo" , "hello" . to_string ( ) ) ?;
46+ fn do_calls ( sbox : & mut MultiUseSandbox ) -> Result < ( ) > {
47+ let res: String = sbox . call_guest_function_by_name ( "Echo" , "hello" . to_string ( ) ) ?;
5048 println ! ( "got Echo res: {res}" ) ;
5149
52- let res: i32 = ctx . call ( "CallMalloc" , 200_i32 ) ?;
50+ let res: i32 = sbox . call_guest_function_by_name ( "CallMalloc" , 200_i32 ) ?;
5351 println ! ( "got CallMalloc res: {res}" ) ;
54- ctx. finish ( )
52+
53+ Ok ( ( ) )
5554}
0 commit comments