Package-level declarations

Types

Link copied to clipboard
object Cbor

Entry points for whole-buffer encoding and decoding.

Link copied to clipboard
data class CborArray(val items: List<CborValue>) : CborValue

Major type 4.

Link copied to clipboard
data class CborBool(val value: Boolean) : CborValue

Simple values false and true.

Link copied to clipboard
class CborBytes(bytes: ByteArray) : CborValue

Major type 2.

Link copied to clipboard
class CborException(message: String, val offset: Int = -1) : KcoapException

Thrown for malformed or unsupported CBOR (RFC 8949), with the byte offset where reading stopped, and for COSE structures that are not what RFC 9052 requires. A KcoapException.

Link copied to clipboard
data class CborInt(val value: Long) : CborValue

Major types 0 and 1. The range is that of Long; larger CBOR integers are rejected on decode.

Link copied to clipboard
data class CborMap(val entries: List<Pair<CborValue, CborValue>>) : CborValue

Major type 5. Entries keep the order they were given or decoded in, because COSE and EDHOC structures are compared byte for byte. Use sortedDeterministically for RFC 8949 §4.2.1 key order.

Link copied to clipboard
data object CborNull : CborValue
Link copied to clipboard
class CborReader(data: ByteArray, start: Int = 0, end: Int = data.size, maxDepth: Int = 32)

Reads CBOR data items one at a time from data, for protocol code that parses a fixed structure or a CBOR sequence (RFC 8742), as EDHOC messages are:

Link copied to clipboard
data class CborSimple(val value: Int) : CborValue

Other simple values (major type 7, 0..19 and 32..255).

Link copied to clipboard
data class CborTag(val tag: Long, val value: CborValue) : CborValue

Major type 6.

Link copied to clipboard
data class CborText(val value: String) : CborValue

Major type 3, always valid UTF-8.

Link copied to clipboard

The eight CBOR major types (RFC 8949 §3.1).

Link copied to clipboard
data object CborUndefined : CborValue
Link copied to clipboard
sealed class CborValue

A decoded CBOR data item (RFC 8949 §3). Values are immutable and compare by content.

Link copied to clipboard

Writes CBOR in preferred serialization (RFC 8949 §4.1): shortest argument encoding and definite lengths only, so the output is deterministic. Calls chain:

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The value as a Long, or an exception naming what was found instead.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard