@@ -132,7 +132,10 @@ impl UninitializedSandbox {
132
132
skip( guest_binary) ,
133
133
parent = Span :: current( )
134
134
) ]
135
- pub fn new ( guest_binary : GuestBinary , cfg : Option < SandboxConfiguration > ) -> Result < Self > {
135
+ pub fn new < ' a > (
136
+ guest_binary : impl std:: borrow:: Borrow < GuestBinary < ' a > > ,
137
+ cfg : Option < SandboxConfiguration > ,
138
+ ) -> Result < Self > {
136
139
#[ cfg( feature = "build-metadata" ) ]
137
140
log_build_details ( ) ;
138
141
@@ -141,12 +144,12 @@ impl UninitializedSandbox {
141
144
check_windows_version ( ) ?;
142
145
143
146
// If the guest binary is a file make sure it exists
144
- let guest_binary = match guest_binary {
147
+ let guest_binary: & GuestBinary = match guest_binary. borrow ( ) {
145
148
GuestBinary :: FilePath ( binary_path) => {
146
149
let path = Path :: new ( & binary_path)
147
150
. canonicalize ( )
148
151
. map_err ( |e| new_error ! ( "GuestBinary not found: '{}': {}" , binary_path, e) ) ?;
149
- GuestBinary :: FilePath (
152
+ & GuestBinary :: FilePath (
150
153
path. into_os_string ( )
151
154
. into_string ( )
152
155
. map_err ( |e| new_error ! ( "Error converting OsString to String: {:?}" , e) ) ?,
@@ -158,7 +161,7 @@ impl UninitializedSandbox {
158
161
let sandbox_cfg = cfg. unwrap_or_default ( ) ;
159
162
160
163
let mut mem_mgr_wrapper = {
161
- let mut mgr = UninitializedSandbox :: load_guest_binary ( sandbox_cfg, & guest_binary) ?;
164
+ let mut mgr = UninitializedSandbox :: load_guest_binary ( sandbox_cfg, guest_binary) ?;
162
165
let stack_guard = Self :: create_stack_guard ( ) ;
163
166
mgr. set_stack_guard ( & stack_guard) ?;
164
167
MemMgrWrapper :: new ( mgr, stack_guard)
0 commit comments