(
name_ptr: i32,
name_len: i32,
response: &mut Owned<WasmSlice>,
)
| 23 | /// Passed in WasmSlice is owned by caller |
| 24 | #[no_mangle] |
| 25 | pub 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…