Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example code for reading an ArrayBufferView? #18

Open
DiThi opened this issue Aug 6, 2017 · 1 comment
Open

Example code for reading an ArrayBufferView? #18

DiThi opened this issue Aug 6, 2017 · 1 comment

Comments

@DiThi
Copy link

DiThi commented Aug 6, 2017

Hi, despite the lack of documentation, examples or tests, I've figured out how to read most values I needed from function arguments. But I haven't been able to read an ArrayBuffer or ArrayBufferView.

Here's one of my attempts:

use v8::*;
fn testf(info: value::FunctionCallbackInfo) -> Result<Value, Value> {
    let arr = info.args[0].into_array_buffer_view().unwrap();
    println!("{:?}", arr);
    Ok(Value::from(value::undefined(&info.isolate)))
}

for which I get

29 |     let arr = info.args[0].into_array_buffer().unwrap();
   |               ^^^^^^^^^^^^ cannot move out of indexed content
@seunlanlege
Copy link

let arr = &info.args[0]
let arr = arr.into_array_buffer().unwrap();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants