A builder that provides ability to build byte packets with no knowledge of it's size. Unlike Java's ByteArrayOutputStream it doesn't copy the whole content every time it's internal buffer overflows but chunks buffers instead. Packet building via build function is O(1) operation and only does instantiate a new ByteReadPacket. Once a byte packet has been built via build function call, the builder could be reused again. You also can discard all written bytes via reset or release. Please note that an instance of builder need to be terminated either via build function invocation or via release call otherwise it will cause byte buffer leak so that may have performance impact.
Read-only immutable byte packet. Could be consumed only once however it does support copy that doesn't copy every byte but creates a new view instead. Once packet created it should be either completely read (consumed) or released via release.
Copy all bytes to the output. Depending on actual input and output implementation it could be zero-copy or copy byte per byte. All regular types such as ByteReadPacket, BytePacketBuilder, Input and Output are always optimized so no bytes will be copied.
Creates a temporary packet view of the packet being build without discarding any bytes from the builder. This is similar to build().copy() except that the builder keeps already written bytes untouched. A temporary view packet is passed as argument to block function and it shouldn't leak outside of this block otherwise an unexpected behaviour may occur.
Apply block of code with buffer's memory providing read range indices. The returned value of block lambda should return number of bytes to be marked as consumed. No read/write functions on this buffer should be called inside of block otherwise an undefined behaviour may occur including data damage.
Read available for read bytes to the destination array range starting at array offset and length bytes. If less than length bytes available then less bytes will be copied and the corresponding number will be returned as result.
Read available for read bytes to the destination array range starting at array offset and length elements. If less than length elements available then less elements will be copied and the corresponding number will be returned as result (possibly zero).
Invoke block function with a temporary Buffer instance taken from the specified pool. Depending on the pool it may be safe or unsafe to capture and use the provided buffer outside of the block. Usually it is always recommended to NOT capture an instance outside.
Invoke block function with a temporary Buffer instance of the specified size in bytes. The provided instance shouldn't be captured and used outside of the block otherwise an undefined behaviour may occur including crash and/or data corruption.
Apply block of code with buffer's memory providing write range indices. The returned value of block lambda should return number of bytes were written. o read/write functions on this buffer should be called inside of block otherwise an undefined behaviour may occur including data damage.