energostack / bisquitt

Bisquitt, a transparent MQTT-SN gateway
Eclipse Public License 2.0
21 stars 3 forks source link

Do not use `io.Reader` and `io.Writer` in packets (de)serialization API #37

Closed mprymek closed 2 years ago

mprymek commented 2 years ago

Go's io.Reader and io.Writer interfaces are semantically overloaded IMHO. There are many possible behaviors of the Read() function according to EOF and stream/packet sources. Implementing all possible scenarios correctly would be complicated and error prone.

On the other way, our packets (de)serialization works strictly on byte buffers and is well-defined. So there is IMHO no reason to use Reader/Writer. If any client code really needs Reader/Writer, it can use e.g. bytes.Buffer as a wrapper...

Merge after #36