sciter-sdk/rust-sciter

Is this the best way to send a `Vec<u8>` of pixels to Sciter as image bytes?

GirkovArpa opened this issue · 3 comments

Briefly, here is what I'm doing which works:

use sciter_serde::{to_value};
use serde_bytes::Bytes;
let bytes: Vec<u8> = my_image_magick_function();
let output = to_value(&Bytes::new(&bytes));
done.call(None, &make_args!(output), None).unwrap()
function onDone(imageBytes) {
  $(img).value = Image.fromBytes(imageBytes);
}

I don't want to perform any unnecessary serialization step, so is there a better way?

I get this error:

expected an Fn<(&[Value],)> closure, found Vec<u8>

Solved:

Value::from(&bytes[..])