phiryll / lexy

Lexicographical Byte Order Encodings
MIT License
0 stars 0 forks source link

Refactor io.Reader/Writer and []byte methods to delegate to each other #88

Closed phiryll closed 2 weeks ago

phiryll commented 4 weeks ago

Can MaxSize() just be Size()? No. The only point of MaxSize() is so the user can preallocate a buffer to use for Put(buf, value).

Can RequiresTerminator() simply be size < 0? Exceptions:

wrt the general task, whichever way makes more sense or is more performant (benchmark!).

phiryll commented 3 weeks ago

If it turns out that the I/O methods almost always delegate to []byte ones, then consider removing them entirely and provide some helper functions for that use case.

Big Issue to Resolve

If the user is actually working with an I/O stream, nillable Codecs and those requiring a terminator are impossible without some additional code on the user's part.

Unless those are additional methods on those specific Codecs? For fixed-length Codecs, using Size() would be sufficient for a (non-member) helper function.

phiryll commented 2 weeks ago

I think lexy is going to abandon the io.Reader/Writer API entirely. There will be a couple adapter functions, but that's it.

If I decide to not do this, this issue can be reopened.