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

Question: Convert uint8_t* in C++ to Vec<u8> in Rust #1311

Open
helenzhangyc opened this issue Feb 5, 2024 · 0 comments
Open

Question: Convert uint8_t* in C++ to Vec<u8> in Rust #1311

helenzhangyc opened this issue Feb 5, 2024 · 0 comments

Comments

@helenzhangyc
Copy link

Hi, I have a uint8_t* in C++ and I want to pass it into my rust code and use it as a Vec<u8>.
The current way I am doing it is converting the uint8_t* to a vector<uint8_t> in C++ and then passing it to rust as a vec: &CxxVector<u8>.
Then, I do let new_vec: Vec<u8> = vec.iter().cloned().collect(); to obtain a Vec<u8> in Rust.

This works fine but takes a long time since my vector is huge (~14GB) and I have to iterate through it and clone it.
I wonder if there is a way to pass the pointer directly into rust and cast it to a Vec<u8> in rust.

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

1 participant