AbstractInput
abstract class AbstractInput : Input
The default abstract base class implementing Input interface.
See Also
Constructors
AbstractInput( AbstractInput( The default abstract base class implementing Input interface. |
Properties
var |
|
val endOfInput: Boolean It is |
|
val
|
|
val |
|
val pool: ObjectPool<ChunkBuffer> |
|
val remaining: Long Number of bytes available for read |
Functions
fun canRead(): Boolean |
|
fun close(): Unit |
|
abstract fun closeSource(): Unit Should close the underlying bytes source. Could do nothing or throw exceptions. |
|
Discards at most n bytes |
|
Discards exactly n bytes or fails with EOFException |
|
fun ensureNextHead(current: ChunkBuffer): ChunkBuffer? |
|
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. open fun fill(): ChunkBuffer? Reads the next chunk suitable for reading or |
|
fun fixGapAfterRead(current: ChunkBuffer): Unit |
|
fun markNoMoreChunksAvailable(): Unit |
|
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 fails with an exception.
It is safe to specify Copy available bytes to the specified buffer but keep them available. If the underlying implementation could trigger bytes population from the underlying source and block until any bytes available |
|
fun prepareReadHead(minSize: Int): ChunkBuffer? |
|
fun readByte(): Byte |
|
fun |
|
fun |
|
fun |
|
fun |
|
fun |
|
fun readText( Read at least min and at most max characters and append them to out |
|
fun readTextExact( Read exactly exactCharacters characters and append them to out Read a string exactly exactCharacters length |
|
fun release(): Unit Release packet. After this function invocation the packet becomes empty. If it has been copied via ByteReadPacket.copy then the copy should be released as well. |
|
fun tryPeek(): Int |
|
Inherited Functions
open fun open fun open fun open fun |
|
open fun open fun open fun open fun |
Extension Properties
For streaming input it should be Input.endOfInput instead. |
|
For streaming input there is no reliable way to detect it without triggering bytes population from the underlying source. Consider using Input.endOfInput or use ByteReadPacket instead. |
Extension Functions
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. |
|
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 |
|
For every byte from this input invokes block function giving it as parameter. |
|
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 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. |
|
Reads exactly n bytes from the input or fails if not enough bytes available. 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 AbstractInput. |
|
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 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> |
|
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. |
|
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 |
Inheritors
abstract class |