-
Notifications
You must be signed in to change notification settings - Fork 1
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
Access to underlying Buffer primitive #7
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As stated in design/BUFFER.md
In multiplatform code, it will be ok to use just
Buffer
, but in platform specific code, near interop with already written Java or Native code, we need to have access to underlying primitive, likeByteBuffer
on JVM andCPointer
orByteArray
(which can be converted toCPointer
) on Native.My use case is using JDK and OpenSSL for cryptography API, where JDK API need ByteArray or ByteBuffer and OpenSSL native API has CPointer. Of course, we may read
ByteArray
fromBuffer
and use it, and also we can createBuffer
fromByteArray
- but this will be not efficient as copies will be created.I would think, that such a functionality should be hidden under some
UnsafeBufferApi
(similar toDelicateCoroutinesApi
) opt-in annotation, as such code will be to easy to misuse.Possible designs:
Buffer
implementation public with public property/function to access underlying primitiveByteBuffer
orByteArray
or other primitive can be accessed both asByteArray
andByteBuffer
The text was updated successfully, but these errors were encountered: