direct

package
v0.33.0-alpha.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2024 License: Apache-2.0 Imports: 1 Imported by: 6

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL