Package-level declarations

Types

Link copied to clipboard
expect interface Closeable

A resource than can be closed. The close method is invoked to release resources an object is holding (e.g. such as open files)

actual typealias Closeable = java.io.Closeable
Link copied to clipboard

Indicates attempt to write on a closed channel (i.e. SdkByteWriteChannel.isClosedForWrite == true) that was closed without a cause. A failed channel rethrows the original SdkByteWriteChannel.close cause exception on send attempts.

Link copied to clipboard
expect open class EOFException(message: String?) : IOException
Link copied to clipboard

Wraps the SdkByteReadChannel so that it compresses into gzip format with each read.

actual class GzipByteReadChannel

Wraps the SdkByteReadChannel so that it compresses into gzip format with each read.

Link copied to clipboard
expect class GzipSdkSource : SdkSource

Wraps the SdkSource so that it compresses into gzip format with each read.

actual class GzipSdkSource

Wraps the SdkSource so that it compresses into gzip format with each read.

Link copied to clipboard
interface Handler<in Request, out Response>

Handler is an (asynchronous) transform from Request ->Response

Link copied to clipboard
expect open class IOException(message: String?, cause: Throwable?) : Exception
actual typealias IOException = java.io.IOException
Link copied to clipboard

A collection of bytes in memory. Moving data from one buffer to another is fast.

Link copied to clipboard
expect sealed interface SdkBufferedSink : SdkSink

A sink that keeps a buffer internally so that callers can do small writes without a performance penalty.

A sink that keeps a buffer internally so that callers can do small writes without a performance penalty.

Link copied to clipboard
expect sealed interface SdkBufferedSource : SdkSource

A source that keeps a buffer internally such that small reads are performant. It also allows peeking ahead, buffering data as necessary, before consuming it.

Link copied to clipboard

Channel for asynchronous reading and writing sequences of bytes. Conceptually a pipe with a reader on one end, decoupled from a writer on the other.

Link copied to clipboard

Supplies an asynchronous stream of bytes. This is a single-reader channel.

Link copied to clipboard

A channel for writing a sequence of bytes asynchronously. This is a single writer channel.

Link copied to clipboard
interface SdkManaged

Interface that the lifecycle of some resource is managed by the SDK at runtime.

Link copied to clipboard
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.

Link copied to clipboard
interface SdkSource : Closeable

A source for reading a stream of bytes (e.g. from file, network, or in-memory buffer). Sources may be layered to transform data as it is read (e.g. to decompress, decrypt, or remove protocol framing).

Properties

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.

Returns a new source that buffers reads from the underlying source. The returned source will perform bulk reads to an in-memory buffer making small reads efficient.

Link copied to clipboard

Read all bytes from this channel into sink. Returns the total number of bytes written.

Link copied to clipboard
suspend fun SdkByteReadChannel.readFully(sink: SdkBuffer, byteCount: Long)

Read exactly byteCount bytes from this into sink or throws EOFException if the channel is exhausted before all bytes could be read.

fun SdkSource.readFully(sink: SdkBuffer, byteCount: Long)

Remove exactly byteCount bytes from this source and appends them to sink.

Link copied to clipboard

Caution Read the entire contents of the channel into sink. This function will suspend until the channel is exhausted and no bytes remain OR the channel cancelled

Link copied to clipboard

Caution Read the entire contents of the channel into a new buffer and return it. This function will suspend until the channel is exhausted and no bytes remain OR the channel cancelled

Link copied to clipboard
actual suspend fun <Error class: unknown class>.readToByteArray(): ByteArray
Link copied to clipboard
fun File.sink(): <Error class: unknown class>

Create a new SdkSink that writes to this file

fun OutputStream.sink(): <Error class: unknown class>

Create a new SdkSource that reads from this InputStream

fun Path.sink(): <Error class: unknown class>

Create a new SdkSink that writes to the file represented by this path

Link copied to clipboard

Returns a new source that reads from the underlying ByteArray

fun InputStream.source(): <Error class: unknown class>

Create a new SdkSource that reads from this InputStream

fun File.source(range: LongRange): <Error class: unknown class>
fun File.source(start: Long = 0, endInclusive: Long = length() - 1): <Error class: unknown class>

Create an SdkSource from the given file and range

fun Path.source(range: LongRange): <Error class: unknown class>
fun Path.source(start: Long = 0, endInclusive: Long = -1): <Error class: unknown class>

Create a SdkSource from the given path and range

Link copied to clipboard
fun <Error class: unknown class>.toInputStream(): InputStream

Create a blocking InputStream that blocks everytime the channel suspends at SdkByteReadChannel.read

Link copied to clipboard
actual fun <Error class: unknown class>.toSdkByteReadChannel(coroutineScope: CoroutineScope?): <Error class: unknown class>
Link copied to clipboard
inline fun <C : Closeable, R> C.use(block: (C) -> R): R

Executes the given block on this resource and then closes it whether an exception has occurred or not.

Link copied to clipboard
suspend fun SdkByteWriteChannel.write(source: ByteArray, offset: Int = 0, limit: Int = source.size - offset)

Write limit bytes from source starting at offset. Suspends until all bytes can be written.

Link copied to clipboard

Removes all bytes from source and writes them to this channel. Returns the total number of bytes read.

Link copied to clipboard

Convenience function to write as many bytes from source as possible without suspending. Returns the number of bytes that could be written.