cbor

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CBOR_TYPE_BYTE_STRING uint8 = 0x40
	CBOR_TYPE_TEXT_STRING uint8 = 0x60
	CBOR_TYPE_ARRAY       uint8 = 0x80
	CBOR_TYPE_MAP         uint8 = 0xa0

	// Only the top 3 bytes are used to specify the type
	CBOR_TYPE_MASK uint8 = 0xe0

	// Max value able to be stored in a single byte without type prefix
	CBOR_MAX_UINT_SIMPLE uint8 = 0x17
)

Variables

This section is empty.

Functions

func Decode

func Decode(dataBytes []byte, dest interface{}) (int, error)

func DecodeById added in v0.4.0

func DecodeById(cborData []byte, idMap map[int]interface{}) (interface{}, error)

Decode CBOR list data by the leading value of each list item. It expects CBOR data and a map of numbers to object pointers to decode into

func DecodeIdFromList added in v0.4.0

func DecodeIdFromList(cborData []byte) (int, error)

Extract the first item from a CBOR list. This will return the first item from the provided list if it's numeric and an error otherwise

func Encode

func Encode(data interface{}) ([]byte, error)

func ListLength added in v0.4.0

func ListLength(cborData []byte) (int, error)

Determine the length of a CBOR list

Types

type ByteString

type ByteString struct {
	// contains filtered or unexported fields
}

Wrapper for bytestrings that allows them to be used as keys for a map

func NewByteString

func NewByteString(data []byte) ByteString

func (ByteString) Bytes

func (bs ByteString) Bytes() []byte

func (ByteString) String

func (bs ByteString) String() string

func (*ByteString) UnmarshalCBOR

func (bs *ByteString) UnmarshalCBOR(data []byte) error

type DecodeStoreCbor added in v0.6.0

type DecodeStoreCbor struct {
	// contains filtered or unexported fields
}

func (*DecodeStoreCbor) Cbor added in v0.6.0

func (d *DecodeStoreCbor) Cbor() []byte

Cbor returns the original CBOR for the object

func (*DecodeStoreCbor) UnmarshalCborGeneric added in v0.6.0

func (d *DecodeStoreCbor) UnmarshalCborGeneric(cborData []byte, dest DecodeStoreCborInterface) error

UnmarshalCborGeneric decodes the specified CBOR into the destination object without using the destination object's UnmarshalCBOR() function

type DecodeStoreCborInterface added in v0.6.0

type DecodeStoreCborInterface interface {
	Cbor() []byte
}

type RawMessage

type RawMessage = _cbor.RawMessage

Create an alias for RawMessage for convenience

type StructAsArray added in v0.4.0

type StructAsArray struct {
	// contains filtered or unexported fields
}

Useful for embedding and easier to remember

type Value

type Value struct {
	Value interface{}
}

Helpful wrapper for parsing arbitrary CBOR data which may contain types that cannot be easily represented in Go (such as maps with bytestring keys)

func (*Value) UnmarshalCBOR

func (v *Value) UnmarshalCBOR(data []byte) error

Jump to

Keyboard shortcuts

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