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

Function say_hello_to

tests/strings/src/lib.rs:25–43  ·  view source on GitHub ↗
(
    name_ptr: i32,
    name_len: i32,
    response: &mut Owned<WasmSlice>,
)

Source from the content-addressed store, hash-verified

23/// Passed in WasmSlice is owned by caller
24#[no_mangle]
25pub unsafe extern "C" fn say_hello_to(
26 name_ptr: i32,
27 name_len: i32,
28 response: &mut Owned<WasmSlice>,
29) {
30 let name = WasmSlice::borrowed(name_ptr, &name_len);
31 let name = name.from_utf8_lossy();
32
33 let hello_to = format!("Hello, {}!", name);
34 println!("{}", hello_to);
35 let hello_to: Owned<WasmSlice> = hello_to.into(); // make this a heap allocated str (this makes capacity == len)
36
37 assert_eq!(
38 hello_to.ptr() as *mut u8,
39 hello_to.as_bytes() as *const [u8] as *mut u8
40 );
41
42 response.replace(hello_to);
43}
44
45/// # Safety
46/// Passed in WasmSlice is owned by caller

Callers

nothing calls this directly

Calls 2

from_utf8_lossyMethod · 0.80
replaceMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…