Returns the exact encoded size of a.
Returns the exact encoded size of a.
Returns an upper bound on the size of a.
Returns an upper bound on the size of a.
Returns a lower bound on the space required in a buffer so that a can
be written.
Returns a lower bound on the space required in a buffer so that a can
be written.
Reads a value of type A from buffer.
Reads a value of type A from buffer. This should generally follow the
contract that writeUnsafe(a, buffer); read(buffer) == a.
This is similar to read(buffer), except that a value does not actually
need to be returned.
This is similar to read(buffer), except that a value does not actually
need to be returned.
Writes a using a ByteBufferMonad.
Writes a using a ByteBufferMonad. This is much slower than just using
writeInit/writeMore.
Writes a entirely to a series of ByteBuffers returned by acquire.
Writes a entirely to a series of ByteBuffers returned by acquire.
The returned set of ByteBuffers is in reverse order, so that calls
to writeAll can be chained by passing in the previous result to used.
Initiate a write.
Initiate a write. If a is successfully written (in its entirety) to
buffer, then None is returned. Otherwise, Some(s) is returned,
indicating that some more data (ie. s) still needs to be written using
writeMore(s, _). This last condition will normally happen when we run
out of space in the buffer, so a was only partially written.
Writes the remaining data from a call to writeInit to buffer.
Writes the remaining data from a call to writeInit to buffer. If this
is written completely and successfully, None is returned. Otherwise,
Some(s2) is returned, which contains more data to be written with
writeMore.
Performs an *unsafe* write of a to buffer.
Performs an *unsafe* write of a to buffer. This does not perform any
safety checks and assumes buffer has at least encodedSize(a) bytes
remaining. The behaviour if this is not the case is undefined.