inline fun writeDirect(size: Int, block: (ByteBuffer) -> Unit): Int
Apply block function on a ByteBuffer of the free space. The block function should return number of written bytes.
Return number of bytes written