Replies: 2 comments 1 reply
-
|
args.get_or_undefined(0) returns a JsValue, so you need to convert it to Uint8Array using js_sys::Uint8Array. Example: use js_sys::Uint8Array; let value = args.get_or_undefined(0); If you need the data as Rust bytes (Vec): let bytes: Vec = uint8_array.to_vec(); Alternatively, you can construct it directly: let bytes = Uint8Array::new(&args.get_or_undefined(0)).to_vec(); Just ensure that the JavaScript side actually passes a Uint8Array, otherwise the cast will fail. |
Beta Was this translation helpful? Give feedback.
-
|
The correct way to do this is essentially use boa_engine::object::builtins::JsUint8Array;
use boa_engine::value::TryFromJs;
let value = args.get_or_undefined(0);
let uint8_array = JsUint8Array::try_from_js(value, context).unwrap() |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
how to convert args.get_or_undefined(0) to Uint8Array ?
Beta Was this translation helpful? Give feedback.
All reactions