(
mut caller: Caller<'_, Self>,
index: u32,
ptr: u32,
len: u32,
)
| 390 | } |
| 391 | |
| 392 | pub fn consume_buffer( |
| 393 | mut caller: Caller<'_, Self>, |
| 394 | index: u32, |
| 395 | ptr: u32, |
| 396 | len: u32, |
| 397 | ) -> anyhow::Result<()> { |
| 398 | let memory = get_memory(&mut caller)?; |
| 399 | let (slice, store) = memory.data_and_store_mut(&mut caller); |
| 400 | |
| 401 | let buffer = store |
| 402 | .buffers |
| 403 | .try_remove(index as usize) |
| 404 | .ok_or(anyhow!("Could not remove slab buffer"))?; |
| 405 | |
| 406 | anyhow::ensure!( |
| 407 | len as usize == buffer.len(), |
| 408 | "bad length passed to consume_buffer" |
| 409 | ); |
| 410 | |
| 411 | slice |
| 412 | .get_mut((ptr as usize)..((ptr + len) as usize)) |
| 413 | .ok_or(anyhow!("Could not fetch slice from WASM memory"))? |
| 414 | .copy_from_slice(&buffer); |
| 415 | |
| 416 | Ok(()) |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | impl wasmtime_wasi::WasiView for WasiHostCtx { |
nothing calls this directly
no test coverage detected