-
Notifications
You must be signed in to change notification settings - Fork 130
Take guestbinary by ref instead of value #560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
af96a45
to
6698c2e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
@@ -132,7 +132,7 @@ impl UninitializedSandbox { | |||
skip(guest_binary), | |||
parent = Span::current() | |||
)] | |||
pub fn new(guest_binary: GuestBinary, cfg: Option<SandboxConfiguration>) -> Result<Self> { | |||
pub fn new(guest_binary: &GuestBinary, cfg: Option<SandboxConfiguration>) -> Result<Self> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Take Borrow<GuestBinary>
, then you can take GuestBinary
or &GuestBinary
. That would also help reduce the number of changes in this PR, as it would be backwards compatible.
pub fn new(guest_binary: &GuestBinary, cfg: Option<SandboxConfiguration>) -> Result<Self> { | |
pub fn new(guest_binary: impl Borrow<GuestBinary>, cfg: Option<SandboxConfiguration>) -> Result<Self> { | |
let guest_binary = guest_binary.borrow(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! Fixed
6698c2e
to
fc417d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
fc417d0
to
453819f
Compare
Signed-off-by: Ludvig Liljenberg <[email protected]>
453819f
to
1b28b07
Compare
Depends on #559
Making
Uninitialized::new
take aGuestBinary
by ref instead of value is more flexible, allowing reuse of the same guest binary across many different sandboxes. This PR allows passing either a ref or value, to be maximally flexible and not be a breaking change