cbor

package
v0.29.6 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DecMode, _ = cbor.DecOptions{}.DecMode()

DecMode is the default DecMode to use when creating a new cbor Decoder

View Source
var EncMode = func() cbor.EncMode {

	options := cbor.CoreDetEncOptions()

	options.Time = cbor.TimeRFC3339Nano
	encMode, err := options.EncMode()
	if err != nil {
		panic(fmt.Errorf("could not extract encoding mode: %w", err))
	}
	return encMode
}()

EncMode is the default EncMode to use when creating a new cbor Encoder

Functions

This section is empty.

Types

type Codec

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

func NewCodec

func NewCodec(opts ...Option) *Codec

NewCodec returns a new cbor Codec with the provided EncMode and DecMode. If either is nil, the default cbor EncMode/DecMode will be used.

func (*Codec) NewDecoder

func (c *Codec) NewDecoder(r io.Reader) encoding.Decoder

func (*Codec) NewEncoder

func (c *Codec) NewEncoder(w io.Writer) encoding.Encoder

type Marshaler

type Marshaler struct{}

func NewMarshaler

func NewMarshaler() *Marshaler

func (*Marshaler) Marshal

func (m *Marshaler) Marshal(val interface{}) ([]byte, error)

func (*Marshaler) MustMarshal

func (m *Marshaler) MustMarshal(val interface{}) []byte

func (*Marshaler) MustUnmarshal

func (m *Marshaler) MustUnmarshal(b []byte, val interface{})

func (*Marshaler) Unmarshal

func (m *Marshaler) Unmarshal(b []byte, val interface{}) error

type Option

type Option func(*Codec)

func WithDecMode

func WithDecMode(decMode cbor.DecMode) Option

WithDecMode sets the DecMode to use when creating a new cbor Decoder.

func WithEncMode

func WithEncMode(encMode cbor.EncMode) Option

WithEncMode sets the EncMode to use when creating a new cbor Encoder.

Jump to

Keyboard shortcuts

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