writeDirect

inline fun Buffer.writeDirect(block: (DataView) -> Int): Int
inline fun <Error class: unknown class>.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


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


inline fun <Error class: unknown class>.writeDirect(size: Int, block: (ByteBuffer) -> 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.

Parameters

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 it 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(block: (CPointer<ByteVar>) -> Int): Int
inline fun Buffer.writeDirect(block: (ByteArray) -> Int): Int