package modes

import "k8s.io/apimachinery/pkg/runtime/serializer/cbor/internal/modes"

Index

Variables

var Decode cbor.DecMode = func() cbor.DecMode {
	decode, err := cbor.DecOptions{

		DupMapKey: cbor.DupMapKeyEnforcedAPF,

		TimeTag: cbor.DecTagOptional,

		MaxNestedLevels: 64,

		MaxArrayElements: 1024,
		MaxMapPairs:      1024,

		IndefLength: cbor.IndefLengthAllowed,

		TagsMd: cbor.TagsAllowed,

		IntDec: cbor.IntDecConvertSignedOrFail,

		MapKeyByteString: cbor.MapKeyByteStringForbidden,

		ExtraReturnErrors: cbor.ExtraDecErrorUnknownField,

		DefaultMapType: reflect.TypeOf(map[string]interface{}(nil)),

		UTF8: cbor.UTF8RejectInvalid,

		FieldNameMatching: cbor.FieldNameMatchingCaseSensitive,

		DefaultByteStringType: reflect.TypeOf(""),

		ByteStringToString: cbor.ByteStringToStringAllowedWithExpectedLaterEncoding,

		FieldNameByteString: cbor.FieldNameByteStringAllowed,

		UnrecognizedTagToAny: cbor.UnrecognizedTagContentToAny,

		TimeTagToAny: cbor.TimeTagToRFC3339Nano,

		ByteStringToTime: cbor.ByteStringToTimeAllowed,

		NaN: cbor.NaNDecodeForbidden,
		Inf: cbor.InfDecodeForbidden,

		ByteStringExpectedFormat: cbor.ByteStringExpectedBase64,

		BignumTag: cbor.BignumTagForbidden,

		SimpleValues: simpleValues,

		BinaryUnmarshaler: cbor.BinaryUnmarshalerNone,
	}.DecMode()
	if err != nil {
		panic(err)
	}
	return decode
}()
var DecodeLax cbor.DecMode = func() cbor.DecMode {
	opts := Decode.DecOptions()
	opts.ExtraReturnErrors &^= cbor.ExtraDecErrorUnknownField
	dm, err := opts.DecMode()
	if err != nil {
		panic(err)
	}
	return dm
}()

DecodeLax is derived from Decode, but does not complain about unknown fields in the input.

var Diagnostic cbor.DiagMode = func() cbor.DiagMode {
	opts := Decode.DecOptions()
	diagnostic, err := cbor.DiagOptions{
		ByteStringText: true,

		MaxNestedLevels:  opts.MaxNestedLevels,
		MaxArrayElements: opts.MaxArrayElements,
		MaxMapPairs:      opts.MaxMapPairs,
	}.DiagMode()
	if err != nil {
		panic(err)
	}
	return diagnostic
}()
var Encode = EncMode{
	// contains filtered or unexported fields
}
var EncodeNondeterministic = EncMode{
	// contains filtered or unexported fields
}

Functions

func RejectCustomMarshalers

func RejectCustomMarshalers(v interface{}) error

Returns a non-nil error if and only if the argument's type (or one of its component types, for composite types) implements json.Marshaler or encoding.TextMarshaler without also implementing cbor.Marshaler and likewise for the respective Unmarshaler interfaces.

This is a temporary, graduation-blocking restriction and will be removed in favor of automatic transcoding between CBOR and JSON/text for these types. This restriction allows CBOR to be exercised for in-tree and unstructured types while mitigating the risk of mangling out-of-tree types in client programs.

Types

type BufferProvider

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

func (*BufferProvider) Get

func (b *BufferProvider) Get() *buffer

func (*BufferProvider) Put

func (b *BufferProvider) Put(buf *buffer)

type EncMode

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

func (EncMode) Marshal

func (em EncMode) Marshal(v interface{}) ([]byte, error)

func (EncMode) MarshalTo

func (em EncMode) MarshalTo(v interface{}, w io.Writer) error

Source Files

buffers.go custom.go decode.go diagnostic.go encode.go

Version
v0.33.0-rc.0
Published
Apr 11, 2025
Platform
js/wasm
Imports
9 packages
Last checked
8 hours ago

Tools for package owners.