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

How to copy byte[] from Java to Rust #96

Closed
pickleburger opened this issue Apr 16, 2024 · 5 comments
Closed

How to copy byte[] from Java to Rust #96

pickleburger opened this issue Apr 16, 2024 · 5 comments

Comments

@pickleburger
Copy link
Contributor

Hello,

I have a method in Java which returns a byte[]. How can I copy the return value into a Rust byte array, e.g. Vec<u8> efficiently (with minimal serialization/deserialization)?

Thanks!

@astonbitecode
Copy link
Owner

Unfortunately, having to_rust handling container types like Vec or Map natively (using jni if they contain basic types) is parked for a while. This is because Rust does not implement reflection and it seems the way to go is implementing a macro.

Maybe the time has come to deal with it. Until this is implemented, I am afraid there is no way to copy Java Lists or Maps to rust without deserialization.

@pickleburger
Copy link
Contributor Author

pickleburger commented Apr 17, 2024

@astonbitecode thanks for the quick response. I'm wondering if you are open to a PR for handling just primitive arrays. I can put up one, since it's needed for my short-term requirements.

@astonbitecode
Copy link
Owner

Sure, please go on for the PR.

@pickleburger
Copy link
Contributor Author

Thank you! I just created #97

Can you please have a look?

@astonbitecode
Copy link
Owner

Implemented in PR #97.

Thanks @pickleburger

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

No branches or pull requests

2 participants