ByteReadPacket
class ByteReadPacket : ByteReadPacketPlatformBase, Input
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.
Constructors
ByteReadPacket( ByteReadPacket(head: IoBuffer, pool: ObjectPool<ChunkBuffer>) |
Functions
fun closeSource(): Unit Should close the underlying bytes source. Could do nothing or throw exceptions. |
|
fun copy(): ByteReadPacket Returns a copy of the packet. The original packet and the copy could be used concurrently. Both need to be either completely consumed or released via release |
|
fun fill(): ChunkBuffer? Reads the next chunk suitable for reading or Read the next bytes into the destination starting at offset at most length bytes. May block until at least one byte is available. Usually bypass all exceptions from the underlying source. |
|
fun toString(): String |
Companion Object Properties
val Empty: ByteReadPacket |
|
val ReservedSize: Int |
Extension Properties
val ByteReadPacket.isEmpty: Boolean |
|
val ByteReadPacket.isNotEmpty: Boolean |
Extension Functions
fun ByteReadPacket.$unsafeAppend$( |
|
fun Input.asStream(): InputStream Convert io.ktor.utils.io Input to java InputStream |
|
fun Input.completeReadHead(current: ChunkBuffer): Unit |
|
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, AbstractInput and AbstractOutput are always optimized so no bytes will be copied. |
|
fun ByteReadPacket. |
|
fun ByteReadPacket.decodeBase64Bytes(): Input Decode ByteReadPacket from base64 format |
|
Discard all remaining bytes. |
|
Discard exactly n bytes or fail if not enough bytes in the input to be discarded. |
|
Discards bytes until delimiter occurred |
|
Discards bytes until of of the specified delimiters delimiter1 or delimiter2 occurred |
|
fun ByteReadPacket.encodeBase64(): String Encode ByteReadPacket in base64 format |
|
fun ByteReadPacket.inputStream(): InputStream Creates InputStream adapter to the packet |
|
fun Input. fun Input. Copy at least min but up to max bytes to the specified destination buffer from this input
skipping offset bytes. If there are not enough bytes available to provide min bytes then
it simply return number of available bytes with no exception so the returned value need
to be checked.
It is safe to specify |
|
fun Input.prepareReadFirstHead(minSize: Int): ChunkBuffer? |
|
fun Input.prepareReadNextHead( |
|
fun ByteReadPacket.readAvailable(dst: ByteBuffer): Int Read at most fun Input.readAvailable( fun Input.readAvailable( fun Input.readAvailable( fun Input.readAvailable( |
|
fun Input.readAvailableLittleEndian( fun Input.readAvailableLittleEndian( fun Input.readAvailableLittleEndian( fun Input.readAvailableLittleEndian( fun Input.readAvailableLittleEndian( fun Input.readAvailableLittleEndian( |
|
fun Input. fun Input. fun Input. |
|
fun ByteReadPacket.readByteBuffer( Read exactly n (optional, read all remaining by default) bytes to a newly allocated byte buffer |
|
fun ByteReadPacket.readBytes( Read exactly n bytes (consumes all remaining if n is not specified but up to Int.MAX_VALUE bytes). Does fail if not enough bytes remaining. Reads all remaining bytes from the input |
|
Reads at least min but no more than max bytes from the input to a new byte array |
|
fun ByteReadPacket.readDirect( |
|
fun ByteReadPacket.readFully(dst: ByteBuffer): Int Read exactly fun Input.readFully( fun Input.readFully( fun Input.readFully( fun Input.readFully( |
|
fun Input.readFullyLittleEndian( fun Input.readFullyLittleEndian( fun Input.readFullyLittleEndian( fun Input.readFullyLittleEndian( fun Input.readFullyLittleEndian( fun Input.readFullyLittleEndian( |
|
fun Input. fun Input. fun Input. |
|
fun ByteReadPacket. fun Input. fun Input. Reads at most max characters decoding bytes with specified decoder. Extra character bytes will remain unconsumed fun Input.readText( Reads at most max characters decoding bytes with specified charset. Extra character bytes will remain unconsumed |
|
Read exactly n characters interpreting bytes in the specified charset. |
|
Read exactly the specified number of bytes interpreting bytes in the specified charset (optional, UTF-8 by default). Read exactly bytesCount interpreting bytes in the specified charset (optional, UTF-8 by default). |
|
Read exactly charactersCount characters interpreting bytes in the specified charset. |
|
fun Input.readUByte(): <ERROR CLASS> |
|
fun Input.readUInt(): <ERROR CLASS> |
|
fun Input.readULong(): <ERROR CLASS> |
|
fun Input.readUShort(): <ERROR CLASS> |
|
fun ByteReadPacket.readUTF8Line( Read a string line considering optionally specified estimate but up to optional limit characters length
(does fail once limit exceeded) or return |
|
fun Input.readUTF8LineTo( Read UTF-8 line and append all line characters to out except line endings. Does support CR, LF and CR+LF |
|
Reads UTF-8 characters until one of the specified delimiters found, limit exceeded or end of stream encountered |
|
fun Input.readUTF8UntilDelimiterTo( fun Input.readUTF8UntilDelimiterTo( Reads UTF-8 characters to out buffer until one of the specified delimiters found, limit exceeded or end of stream encountered fun Input. |
|
fun Input.readUntilDelimiter( Copies to dst array at offset at most length bytes or until the specified delimiter occurred. Copies to dst output until the specified delimiter occurred. |
|
fun Input.readUntilDelimiters( Copies to dst array at offset at most length bytes or until one of the specified delimiters delimiter1 or delimiter2 occurred. Copies to dst output until one of the specified delimiters delimiter1 or delimiter2 occurred. |
|
fun ByteReadPacket.readerUTF8(): Reader Creates Reader from the byte packet that decodes UTF-8 characters |
|
Invoke block function for every chunk until end of input or block function return |
|
Invoke block function for every chunk until end of input or block function return zero block function returns number of bytes required to read next primitive and shouldn’t require too many bytes at once otherwise it could fail with an exception. It is not guaranteed that every chunk will have fixed size but it will be always at least requested bytes length. block function should never release provided buffer and should not write to it otherwise an undefined behaviour could be observed |