Package-level declarations

Concise Binary Object Representation (CBOR) format implementation, as per RFC 7049.

Types

Link copied to clipboard

Specifies that a ByteArray shall be encoded/decoded as CBOR major type 2: a byte string. For types other than ByteArray, ByteString will have no effect.

Link copied to clipboard

Implements encoding and decoding classes to/from bytes using CBOR specification. It is typically used by constructing an application-specific instance, with configured behaviour, and, if necessary, registered custom serializers (in SerializersModule provided by serializersModule constructor parameter).

Link copied to clipboard

Encode a class as a CBOR Array (Major type 4) instead of a CBOR map.

Link copied to clipboard

Builder of the Cbor instance provided by Cbor factory function.

Link copied to clipboard

Configuration of the current Cbor instance available through Cbor.configuration.

Link copied to clipboard

This interface provides access to the current Cbor instance, so it can be properly taken into account in a custom serializer. For example, a custom serializer can decode CBOR data wrapped into a byte array using Cbor.decodeFromByteArray as required by some COSE structures. The actual CBOR Decoder used during deserialization implements this interface, so it is possible to cast the decoder passed to KSerializer.deserialize to CborDecoder when implementing such low-level serializers, to access configuration properties:

Link copied to clipboard

This interface provides access to the current Cbor instance, so it can be properly taken into account in a custom serializer. For example, a custom serializer can output a byte array using Cbor.encodeToByteArray and embed resulting data into the output, as required, by some COSE structures. The actual CBOR Encoder used during serialization implements this interface, so it is possible to cast the encoder passed to KSerializer.serialize to CborEncoder when implementing such low-level serializers, to access configuration properties:

Link copied to clipboard

CBOR supports keys of all sorts, not just Strings. In the COSE context, these keys are called labels and are limited to Strings and 64-bit negative integers and 64-bit unsigned integers. Conceptually, these work just as SerialNames, but to also support numbers in addition to Strings, this annotation can be used.

Link copied to clipboard
object CborTag

Contains a set of predefined tags, named in accordance with RFC 8949 3.4. Tagging of Items

Link copied to clipboard

Specifies that a key (i.e. a property identifier) shall be tagged and serialized as CBOR major type 6: optional semantic tagging of other major types.

Link copied to clipboard

Specifies that an object of a class annotated using ObjectTags shall be tagged and serialized as CBOR major type 6: optional semantic tagging of other major types. Can be combined with CborArray and ValueTags. Note that ObjectTags will always be encoded directly before to the data of the tagged object, i.e. a value-tagged property of an object-tagged type will have the value tags preceding the object tags.

Link copied to clipboard

Specifies that a property shall be tagged and the tag is serialized as CBOR major type 6: optional semantic tagging of other major types.

Functions

Link copied to clipboard
fun Cbor(from: Cbor = Cbor, builderAction: CborBuilder.() -> Unit): Cbor

Creates an instance of Cbor configured from the optionally given Cbor instance and adjusted with builderAction.