INNER CODE UNIT · Rust
get_memory
lunatic-solutions/lunatic · crates/lunatic-common-api/src/lib.rs:9
pub fn get_memory<T>(caller: &mut Caller<T>) -> Result<Memory> {
caller
.get_export("memory")
.or_trap("No export `memory` found")?
.into_memory()
.or_trap("Export `memory` is not a memory")
}
// Call guest to allocate a Vec of size `size`
pub fn allocate_guest_memory<'a, T: Send>(
caller: &'a mut Caller<T>,
size: u32,
) -> Pin<Box<dyn Future<Output = Result<u32>> + Send + 'a>> {
Box::pin(async move {
let mut results = [Val::I32(0)];
caller
.get_export(ALLOCATOR_FUNCTION_NAME)
.or_trap(format!("no export named {ALLOCATOR_FUNCTION_NAME} found"))?