pub trait SandboxMemory: Sized + Clone {
    fn new(initial: u32, maximum: Option<u32>) -> Result<Self, Error>;
    fn get(&self, ptr: u32, buf: &mut [u8]) -> Result<(), Error>;
    fn set(&self, ptr: u32, value: &[u8]) -> Result<(), Error>;
}
Expand description

Reference to a sandboxed linear memory, that will be used by the guest module.

The memory can’t be directly accessed by supervisor, but only through designated functions get and set.

Required Methods§

Construct a new linear memory instance.

The memory allocated with initial number of pages specified by initial. Minimal possible value for initial is 0 and maximum possible is 65536. (Since maximum addressable memory is 232 = 4GiB = 65536 * 64KiB).

It is possible to limit maximum number of pages this memory instance can have by specifying maximum. If not specified, this memory instance would be able to allocate up to 4GiB.

Allocated memory is always zeroed.

Read a memory area at the address ptr with the size of the provided slice buf.

Returns Err if the range is out-of-bounds.

Write a memory area at the address ptr with contents of the provided slice buf.

Returns Err if the range is out-of-bounds.

Implementors§