cbor

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package cbor implements just enough of the CBOR (Concise Binary Object Representation, RFC 8948) to deterministically encode simple data. It does not include decoding as it is not needed for the purpose of this package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

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

Array is the CBOR array type.

func NewArray

func NewArray(elts ...Cbor) Array

NewArray reutnrs a CBOR array data item, containing the specified elements.

func (Array) Append

func (a Array) Append(c Cbor) Array

Append appends CBOR data items to an existing Array.

func (Array) Encode

func (a Array) Encode(w io.Writer) error

Encode implements the Cbor interface.

type Bool

type Bool byte

Bool is the type of CBOR booleans.

func NewBool

func NewBool(b bool) Bool

NewBool returns a CBOR boolean data item.

func (Bool) Encode

func (b Bool) Encode(w io.Writer) error

Encode implements the Cbor interface.

type Cbor

type Cbor interface {
	// Encode deterministically writes the CBOR-encoded data to the stream.
	Encode(w io.Writer) error
}

Cbor is a CBOR (RFC8949) data item that can be encoded to a stream.

type Entry

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

Entry is a key/value pair in a CBOR map.

func NewEntry

func NewEntry(key, val Cbor) Entry

NewEntry returns a CBOR key/value pair for use in a Map.

type Map

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

Map is the CBOR map type.

func NewMap

func NewMap(entries ...Entry) Map

NewMap returns a CBOR map data item containing the specified entries. Duplicate keys in the Map will cause an error when Encode is called.

func (Map) Add

func (m Map) Add(key, val Cbor) Map

Add adds a key/value entry to an existing Map. Duplicate keys in the Map will cause an error when Encode is called.

func (Map) Encode

func (m Map) Encode(w io.Writer) error

Encode implements the Cbor interface.

type Text

type Text string

Text is the CBOR text string type.

func NewText

func NewText(s string) Text

NewText returns a CBOR text string data item.

func (Text) Encode

func (s Text) Encode(w io.Writer) error

Encode implements the Cbor interface.

type Uint

type Uint uint64

Uint is the CBOR unsigned integer type.

func NewUint

func NewUint(n uint64) Uint

NewUint returns a CBOR unsigned integer data item.

func (Uint) Encode

func (n Uint) Encode(w io.Writer) error

Encode implements the Cbor interface.

Jump to

Keyboard shortcuts

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