inline fun BytePacketBuilder.writeDirect(
    size: Int,
    block: (ByteBuffer) -> Unit
): Unit

Write bytes directly to packet builder’s segment. Generally shouldn’t be used in user’s code and useful for efficient integration.

Invokes block lambda with one byte buffer. block lambda should change provided’s position accordingly but shouldn’t change any other pointers.


size - minimal number of bytes should be available in a buffer provided to the lambda. Should be as small as possible. If size is too large then the function may fail because the segments size is not guaranteed to be fixed and not guaranteed that is will be big enough to keep size bytes. However it is guaranteed that the segment size is at least 8 bytes long (long integer bytes length)

inline fun Buffer.writeDirect(
    size: Int = 1,
    block: (ByteBuffer) -> Unit
): Int