(
&self,
store: &mut Store,
env: &WasiFunctionEnv,
bytes: &[u8],
f: impl FnOnce(&mut Store, i32) -> Result<R>,
)
| 2877 | } |
| 2878 | |
| 2879 | fn with_bytes<R>( |
| 2880 | &self, |
| 2881 | store: &mut Store, |
| 2882 | env: &WasiFunctionEnv, |
| 2883 | bytes: &[u8], |
| 2884 | f: impl FnOnce(&mut Store, i32) -> Result<R>, |
| 2885 | ) -> Result<R> { |
| 2886 | let ptr = self.allocate(store, bytes.len() as i32)?; |
| 2887 | self.run_and_free(store, ptr, |store, ptr| { |
| 2888 | let view = env |
| 2889 | .data(&*store) |
| 2890 | .try_memory_view(&*store) |
| 2891 | .context("get WASIX memory view")?; |
| 2892 | view.write(ptr as u64, bytes) |
| 2893 | .with_context(|| format!("write guest bytes at 0x{ptr:x}"))?; |
| 2894 | f(store, ptr) |
| 2895 | }) |
| 2896 | } |
| 2897 | |
| 2898 | fn with_allocation<R>( |
| 2899 | &self, |
no test coverage detected