MCPcopy Create free account
hub / github.com/bluejekyll/wasmtime-java / into_java

Method into_java

wasmtime-jni/src/wasm_value.rs:326–348  ·  view source on GitHub ↗
(
        self,
        env: &JNIEnv<'j>,
        wasm_alloc: Option<&WasmAlloc>,
        mut store: S,
    )

Source from the content-addressed store, hash-verified

324struct IntoByteBuffer(WasmSlice);
325impl IntoJavaObject for IntoByteBuffer {
326 unsafe fn into_java<'j, S: AsContextMut>(
327 self,
328 env: &JNIEnv<'j>,
329 wasm_alloc: Option<&WasmAlloc>,
330 mut store: S,
331 ) -> Result<JObject<'j>, Error> {
332 let wasm_alloc =
333 wasm_alloc.ok_or_else(|| anyhow!("WasmAlloc is required for this return type"))?;
334 let bytes = wasm_alloc.as_mut(self.0, &mut store);
335
336 debug!(
337 "length of bytes for ByteBuffer: {} expected len: {}",
338 bytes.len(),
339 self.0.len()
340 );
341 debug!("read bytes from wasm_slice: {:x?}", bytes);
342
343 let buffer = env
344 .new_direct_byte_buffer(bytes)
345 .context("Failed to create new ByteBuffer")?;
346
347 Ok(buffer.into())
348 }
349}
350
351struct IntoByteArray(WasmSlice);

Callers 2

load_from_argsMethod · 0.80

Calls 1

as_mutMethod · 0.45

Tested by

no test coverage detected