Feed

abstract inner class Feed : EncoderDecoder.Feed<C> (source)

Data to encode is fed into consume and, as the Encoder.Feed's buffer fills, encoded data is output to the supplied Encoder.OutFeed. This allows for a "lazy" encode, or streaming of encoded data.

Once all data has been fed through consume, call doFinal to process remaining data in the Encoder.Feed buffer. Alternatively, utilize the use extension function (highly recommended) which will call doFinal (or close if there was an error with encoding) for you.

See also

Constructors

Link copied to clipboard
constructor(_out: Encoder.OutFeed)

Properties

Link copied to clipboard
@get:JvmName(name = "_out")
protected var _out: Encoder.OutFeed

For implementations to pass in as a constructor argument and reference while performing encoding operations. Upon close being called, this is set to the Encoder.OutFeed.NoOp instance which ensures any local object references that the initial OutFeed has are not leaked and can be promptly GCd.

Functions

Link copied to clipboard
override fun close()

Closes the feed rendering it useless.

Link copied to clipboard
fun consume(input: Byte)

Updates the Encoder.Feed with a new byte to encode.

Link copied to clipboard
protected abstract fun consumeProtected(input: Byte)
Link copied to clipboard
protected abstract override fun doFinalProtected()

Implementations should perform final operations on their buffered input, AND reset any stateful variables they may have. This is called by both flush and doFinal.

Link copied to clipboard
override fun flush()

Flushes the buffered input and performs any final encoding operations without closing the Feed.

Link copied to clipboard
override fun isClosed(): Boolean