Open BurntSushi opened 9 years ago
Yeah, the initial version was just quickly whipped up without much thought. I've been wanting to rewrite it for a little while now that I have a bit of experience with the Read and Write traits.
Thanks for the link, I'll have a look at it after work :) I start at 4 am, so I probably won't have anything up today, but tomorrow looks promising
@CruzBishop Awesome! No rush. :-)
I just came across your library, and I'm curious about the rationale for the current implementation. In particular, it looks like encoding a varint requires an allocation (specifically, a
VecDeque
). This seems very heavyweight.The README mentions that this doesn't implement methods for writing to a stream/buffer, but it seems to me that methods for writing to a stream/buffer are actually much more fundamental than requiring an allocation.
For inspiration, I'd suggest looking at Go's standard library
encoding/binary
package. Half of it is for writing fixed size numbers, but the other half is for variable integer decoding. I'd expect a Rust API to look pretty similar: http://golang.org/pkg/encoding/binary/The key is that a "buffer" can actually be stack allocated, so it allows the caller a lot more freedom.