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.
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/binarypackage. 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.