Skip to content

Support enif_make_resource_binary #452

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

Closed
cigrainger opened this issue May 9, 2022 · 2 comments
Closed

Support enif_make_resource_binary #452

cigrainger opened this issue May 9, 2022 · 2 comments

Comments

@cigrainger
Copy link

cigrainger commented May 9, 2022

This is in rustler_sys, but it would be nice to have it wrapped more safely in rustler.

I'd be happy to contribute this one but could use some guidance on the API. I was thinking it would make sense to add ResourceBinary to rustler::resource (though maybe it should live in rustler::types::binary?). ResourceBinary::new would take a ResourceArc and a reference to a binary with a lifetime tied to the resource object. It would hold the cloned ResourceArc and the reference to the binary as well as the size of the binary.

Does that sound reasonable? Other than lifetime annotations, are there any other considerations for ensuring the binary data is handled properly if it's external to the resource object?

@josevalim
Copy link
Contributor

This can now be closed thanks to #487. :) /cc @filmor

@filmor
Copy link
Member

filmor commented Sep 18, 2022

Fixed in #487, you can now use resource_arc.make_binary(|inner| &inner.some_binary) to create a resource binary.

@filmor filmor closed this as completed Sep 18, 2022
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

Successfully merging a pull request may close this issue.

3 participants