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

Alternative design for SizeLimit #160

Closed
dtolnay opened this issue Apr 28, 2017 · 1 comment
Closed

Alternative design for SizeLimit #160

dtolnay opened this issue Apr 28, 2017 · 1 comment
Milestone

Comments

@dtolnay
Copy link
Collaborator

@dtolnay dtolnay commented Apr 28, 2017

It looks like the large majority of Bincode users on GitHub are using Infinite as the size limit. It would be nice to redesign the API to accommodate this use case more ergonomically.

@dtolnay
Copy link
Collaborator Author

@dtolnay dtolnay commented Apr 28, 2017

In particular, serializing with a bounded size is equivalent to checking bincode::serialized_size_bounded followed by serializing the thing normally, so that is already well supported.

Deserializing with a bounded size is equivalent to deserializing from an io::Read that limits the number of bytes that you can read from it. Maybe consider providing such a reader in an external crate.

let bounded = limit::reader(r, 50<<20);
bincode::deserialize_from(bounded)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.