SdkSink

interface SdkSink : Closeable

A destination for writing a stream of bytes (e.g. file, network, in-memory buffer). Sinks may be layered to transform received data, such as to compress, encrypt, throttle, or add protocol framing.

Most application code should not operate on a sink directly, but rather a SdkBufferedSink which is more convenient. Use SdkSink.buffer to wrap any sink with a buffer.

Thread/Coroutine Safety

Sinks are not thread safe by default. Do not share a sink between threads or coroutines without external synchronization.

This is a blocking interface! Use from coroutines should be done from an appropriate dispatcher (e.g. Dispatchers.IO).

Inheritors

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract override fun close()

Pushes all buffered bytes to their final destination and releases resources held by this sink. It is an error to write to a closed sink. This is an idempotent operation.

Link copied to clipboard
abstract fun flush()

Pushes all buffered bytes to their final destination

Link copied to clipboard
abstract fun write(source: SdkBuffer, byteCount: Long)

Removes byteCount bytes from source and appends them to this.

Inherited functions

Link copied to clipboard

Returns a new sink that buffers writes to the sink. Writes will be efficiently "batched". Call SdkSink.flush when done to emit all data to the underlying sink.

Link copied to clipboard
fun SdkSink.toOkio(): <Error class: unknown class>