encoder

package
v0.16.7-rc.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(v any) ([]byte, error)

Marshal returns encoding of param v

func RegisterType

func RegisterType(rType reflect.Type) error

RegisterType gives a unique CBOR tag to a type. Only call this from encoder/registry's init().

func Unmarshal

func Unmarshal(b []byte, v any) error

Unmarshal decodes param v from []byte b

func UnmarshalFirst added in v0.15.17

func UnmarshalFirst(b []byte, v any) ([]byte, error)

UnmarshalFirst decodes the first CBOR data item into param v and returns the remaining bytes

func UnmarshalStrict added in v0.16.7

func UnmarshalStrict(b []byte, v any) error

UnmarshalStrict decodes without type tags and fails on a wire key with no matching field. Only projection drift tests need it.

Types

type Encoder added in v0.3.0

type Encoder interface {
	Encode(v any) error
}

func NewEncoder added in v0.3.0

func NewEncoder(w io.Writer) Encoder

NewEncoder returns a new encoder that writes to w

type RawMessage added in v0.16.7

type RawMessage []byte

RawMessage is an item that is already CBOR encoded.

func (RawMessage) MarshalCBOR added in v0.16.7

func (m RawMessage) MarshalCBOR() ([]byte, error)

Returns the same bytes

func (*RawMessage) UnmarshalCBOR added in v0.16.7

func (m *RawMessage) UnmarshalCBOR(data []byte) error

Creates a copy of the bytes

type SelfDecoder added in v0.16.7

type SelfDecoder interface {
	UnmarshalCBOR([]byte) error // fxamacker
}

SelfDecoder is the hook a type implements to read its own encoding.

type SelfEncoder added in v0.16.7

type SelfEncoder interface {
	MarshalCBOR() ([]byte, error) // fxamacker
}

SelfEncoder is the hook a type implements to write its own encoding.

type UnmarshalTypeError added in v0.16.7

type UnmarshalTypeError = cbor.UnmarshalTypeError

UnmarshalTypeError is a wire item that does not fit the Go type, as opposed to malformed input.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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