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

Provide the ability to write to existing typed arrays #503

Open
nex3 opened this issue Jun 2, 2023 · 1 comment
Open

Provide the ability to write to existing typed arrays #503

nex3 opened this issue Jun 2, 2023 · 1 comment
Labels
Wishlist Things we'd want in the future

Comments

@nex3
Copy link

nex3 commented Jun 2, 2023

Currently the only way to access the binary serialization of a protocol buffer is using the toBinary() method which returns its own newly-allocated Uint8Array. If the protobuf needs to be written to a specific existing buffer, for example to include it adjacent to other data, it has to be recopied from the returned value which may be inefficient for large amounts of data or frequent transfers.

It would be great to have something like a writeToArray(array: Uint8Array, position: int = 0) method to write directly to an existing data buffer (along with a binaryLength getter so we can know how much space to allocate).

@smaye81
Copy link
Member

smaye81 commented Jun 5, 2023

Hi @nex3. This is a nice idea. Let us think through the best way to implement this. Thanks for reaching out.

@smaye81 smaye81 added the Wishlist Things we'd want in the future label Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Wishlist Things we'd want in the future
Projects
None yet
Development

No branches or pull requests

2 participants