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

Get number of bytes written/read? #54

Closed
alexreg opened this issue Feb 5, 2016 · 6 comments
Closed

Get number of bytes written/read? #54

alexreg opened this issue Feb 5, 2016 · 6 comments

Comments

@alexreg
Copy link

@alexreg alexreg commented Feb 5, 2016

Could the serialize_into and deserialize_from methods return the number of bytes written/read respectively? This would both handy and more efficient, since you already have to compute these values in these methods, and it thus saves an extra call to serialized_size.

@alexreg
Copy link
Author

@alexreg alexreg commented Feb 5, 2016

Hmm, on second though, I'm not sure how easy this is to add to code.

@TyOverby
Copy link
Collaborator

@TyOverby TyOverby commented Feb 7, 2016

If you use the structs defined here to do the deserialization you can grab the number of bytes read.

By using the function encoded_size, you can get the size of the struct as it would be on the wire.

@alexreg
Copy link
Author

@alexreg alexreg commented Feb 7, 2016

It doesn't seem to be documented how to use those structs directly.

@TyOverby
Copy link
Collaborator

@TyOverby TyOverby commented Feb 8, 2016

I've added documentation to rustc-serizlize DecoderReader and serde Deserializer. The encoded_size and serialized_size functions are already documented.

@TyOverby TyOverby closed this Feb 8, 2016
@alexreg
Copy link
Author

@alexreg alexreg commented Feb 8, 2016

Thanks for this. That’s quite handy.

Not sure if it bothers you, but there’s a typo in the docs – “bytes_red”. Otherwise good.

On 8 Feb 2016, at 01:36, Ty Overby notifications@github.com wrote:

I've added documentation to rustc-serizlize DecoderReader http://tyoverby.com/bincode/bincode/rustc_serialize/struct.DecoderReader.html and serde Deserializer http://tyoverby.com/bincode/bincode/serde/struct.Deserializer.html. The encoded_size and serialized_size functions are already documented.


Reply to this email directly or view it on GitHub #54 (comment).

@TyOverby
Copy link
Collaborator

@TyOverby TyOverby commented Feb 8, 2016

aah! Thanks!

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.

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