MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / with_bytes

Method with_bytes

src/pglite/postgres_mod.rs:2879–2896  ·  view source on GitHub ↗
(
        &self,
        store: &mut Store,
        env: &WasiFunctionEnv,
        bytes: &[u8],
        f: impl FnOnce(&mut Store, i32) -> Result<R>,
    )

Source from the content-addressed store, hash-verified

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,

Callers 1

push_inputMethod · 0.80

Calls 4

allocateMethod · 0.80
lenMethod · 0.80
run_and_freeMethod · 0.80
writeMethod · 0.80

Tested by

no test coverage detected