Closed WeismannS closed 1 year ago
https://docs.rs/neon/1.0.0-alpha.2/neon/types/buffer/trait.TypedArray.html#tymethod.from_slice
use neon::types::JsUint8Array;
// Replace with the real data in a `Vec<u8>`
let data: Vec<u8> = vec![1, 2, 3, 4];
JsUint8Array::from_slice(&data)
Note, as of writing this is only available in the 1.0 pre-release (1.0.0-alpha.2). In 0.10
, there is a bit more boilerplate.
let mut buf = cx.array_buffer(data.len());
buf.as_mut_slice(&mut cx).copy_from_slice(&data);
Ok(buf)
As linked above, that method is on the TypedArray
trait which needs to be in scope to call it.
use neon::types::buffer::TypedArray;
I hope this helps. I'm going to close this issue since it's more of a support request than an issue with Neon. Cheers!
Code snipper: I'm using the
image
andimageproc
crates