#[repr(C)]pub struct Desc {
pub ptr: usize,
pub len: usize,
}Expand description
How a guest hands a (pointer, length) pair back to the host.
The obvious alternative is packing both into the single i64 a wasm export
can return. That works only while pointers are 32 bits. Returning a pointer
to this struct instead costs one extra memory read per call and keeps every
export signature unchanged under a 64-bit guest, where usize simply widens.
Do not replace this with bit-packing; that is precisely what it exists to
avoid. The host reads exactly 2 * size_of::<usize>() bytes at the returned
address and splits them down the middle, so this layout is load-bearing —
hence #[repr(C)], and hence the tests pinning its size and field order.
Fields§
§ptr: usizeAddress of the payload.
len: usizePayload length, in bytes.
Auto Trait Implementations§
impl Freeze for Desc
impl RefUnwindSafe for Desc
impl Send for Desc
impl Sync for Desc
impl Unpin for Desc
impl UnsafeUnpin for Desc
impl UnwindSafe for Desc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more