-
-
Notifications
You must be signed in to change notification settings - Fork 274
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
Support retrieving the bytes written from encode #703
Comments
You can try using the https://docs.rs/bincode/2.0.0-rc.3/bincode/enc/write/struct.SizeWriter.html I don't see a better way of doing this in bincode. However that means that most of your data structures will be iterated over multiple times. |
@VictorKoenders Thanks for the pointer, I gave that a go but felt it didn't quite fit my use case, although ultimately that's on me for trying to force bincode to suit my needs. I ended up going with a more manual parsing approach (bit hacky and WIP for now)
One thing I did find on the decoding side that often I have a need to take n number of bytes, which is dynamic based upon prior decoding, e.g:
I wonder what the general thoughts of the maintainers would be on adding an additional function to the
Which would enable implementing custom Decoders with a bit more ease? Happy to look into this myself and try raise a PR. |
Unfortunately we cannot provide a method that returns We're considering switching to an API more similar to rust-lang/rust#78485, but that has not stabilized yet |
Ah okay that's interesting, hadn't considered it in a |
Returning With the Rendered version: https://github.com/rust-lang/rfcs/blob/master/text/2930-read-buf.md#summary |
OKay great, thanks for the info, will track this closely! |
Am writing an encoder for RabbitMQ, one of the implementations (trivalised) looks like this:
However before encoding the keys and values, I need to encode the total number of bytes that the
Table
will be.Apologies is there is already a way to do this!
The text was updated successfully, but these errors were encountered: