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

Add ser/deser from Read/Write #23

Open
Yamakaky opened this issue Oct 18, 2020 · 4 comments
Open

Add ser/deser from Read/Write #23

Yamakaky opened this issue Oct 18, 2020 · 4 comments

Comments

@Yamakaky
Copy link

Yamakaky commented Oct 18, 2020

For the binary serialization especially, it would be nice to be able to serde using the standard Read and Write traits instead of using Vec and slice.

I'm working on interaction between rust and wasm (using wasmer). On the host, I first have to serialize the value to Vec then copy it to wasm. Same thing for deser. With custom Read/Write types, I could do it in one pass.

One other advantage is that you could do streaming deserialization with custom parsers, for example if you want to add all the u32 in a very big file with low constant memory usage.

It can be added as a backward compatible method since Vec is Read + Write. Then, in a future version, the Vec version can be dropped.

@Yamakaky
Copy link
Author

Example of what it could look like: master...Yamakaky:read-write

The Result<Result<>> is ugly, it would be merged in one Error type in a final version.

@Yamakaky
Copy link
Author

Would you be willing to merge such feature? If not, I won't bother putting it in order.

@not-fl3
Copy link
Owner

not-fl3 commented Oct 28, 2020

Sorry for such a delayed response on this.

I do agree that this is a great feature that would be nice to have, but I am not quite sure about the proposed API.

@Yamakaky
Copy link
Author

Yamakaky commented Oct 28, 2020

Do you mean the Result<Result<>>?

ser_bin and de_bin could be put as free functions unless we find a usecase where the default implementation could be optimized.

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

2 participants