You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow host to pass reference types (&[u8] and &str) to guest funcs #1987
Sandbox::call only accepts owned string and byte arguments: String, Vec<u8> and Vec<Bytes>. Guest call_host has the same limit. Hyperlight never needs ownership, because arguments are only borrowed and copied once into the virtqueue. A user holding a &[u8] or &str must clone it first, for example sandbox.call("f", bytes.to_vec()), which costs an extra allocation and copy.
For bytes, users must also pick the type that matches the guest function's parameter:
Vec<u8> (VecBytes): the guest copies the bytes into a Vec<u8>.
Vec<Bytes> (ByteChunks): the guest keeps Bytes handles to the transport buffers without copying.
Fix:
Accept &str and &[u8] arguments, and keep accepting owned ones.
Send all byte arguments in one format, and let the guest function's parameter type decide how to read them. A Vec<Bytes> parameter keeps the transport buffers without copying, and a Vec<u8> parameter copies once.
Activity