package direct

import "k8s.io/apimachinery/pkg/runtime/serializer/cbor/direct"

Package direct provides functions for marshaling and unmarshaling between arbitrary Go values and CBOR data, with behavior that is compatible with that of the CBOR serializer. In particular, types that implement cbor.Marshaler and cbor.Unmarshaler should use these functions.

Index

Functions

func Diagnose

func Diagnose(src []byte) (string, error)

Diagnose accepts well-formed CBOR bytes and returns a string representing the same data item in human-readable diagnostic notation (RFC 8949 Section 8). The diagnostic notation is not meant to be parsed.

func Marshal

func Marshal(src interface{}) ([]byte, error)

Marshal serializes a value to CBOR. If there is more than one way to encode the value, it will make the same choice as the CBOR implementation of runtime.Serializer.

Note: Support for CBOR is at an alpha stage. If the value (or, for composite types, any of its nested values) implement any of the interfaces encoding.TextMarshaler, encoding.TextUnmarshaler, encoding/json.Marshaler, or encoding/json.Unmarshaler, a non-nil error will be returned unless the value also implements the corresponding CBOR interfaces. This limitation will ultimately be removed in favor of automatic transcoding to CBOR.

func Unmarshal

func Unmarshal(src []byte, dst interface{}) error

Unmarshal deserializes from CBOR into an addressable value. If there is more than one way to unmarshal a value, it will make the same choice as the CBOR implementation of runtime.Serializer.

Note: Support for CBOR is at an alpha stage. If the value (or, for composite types, any of its nested values) implement any of the interfaces encoding.TextMarshaler, encoding.TextUnmarshaler, encoding/json.Marshaler, or encoding/json.Unmarshaler, a non-nil error will be returned unless the value also implements the corresponding CBOR interfaces. This limitation will ultimately be removed in favor of automatic transcoding to CBOR.

Source Files

direct.go

Version
v0.32.0-rc.2
Published
Dec 5, 2024
Platform
js/wasm
Imports
1 packages
Last checked
14 hours ago

Tools for package owners.