bowmap-9 Improve readers and writers

Bowmap · bowmap.git · Tickets

A Bowmap Ticket (Closed):

Ticket · History

Readers and writers use

Readers fully rely on mutating a ByteBuf.

Writers rely on a buffer protocol which only has write-byte!. They are fully built around functions of (buf, x) -> buf, which is good, though bufs can still be mutated, and have to be of the specific buffer protocol.

Readers and writers are untested, and testing them requires creating these mutable things (or an implementation of the buffer protocol)

No validation is done when reading or writing packets, which can lead to bad values being read in my a malicious (or otherwise buggy) client, and obviously bad values being sent out without the server knowing.

Transforming/conforming data inside of NBT and JSON writers cannot be trivially done, and requires data to be conformed before being passed into the writers.

Readers and writers both rely heavily on vars, when they should be able to inline into a stack of function calls.

Idea

Build up reusable 'readers' and 'writers', which can work on any collection of bytes, and can validate and conform their input/output.

Reading needs to pull in arbitrary bytes, so an iterator seems fine as reduction + reduced would require keeping track of things.

Writers can be generalized into a reducing function, as they already are with byte>, but without depending on a buffer abstraction directly.