modes

package
v0.31.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.ByteStringToStringAllowed,

		FieldNameByteString: cbor.FieldNameByteStringAllowed,

		UnrecognizedTagToAny: cbor.UnrecognizedTagContentToAny,
	}.DecMode()
	if err != nil {
		panic(err)
	}
	return decode
}()
View Source
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.

View Source
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
}()
View Source
var Encode cbor.EncMode = func() cbor.EncMode {
	encode, err := cbor.EncOptions{

		Sort: cbor.SortBytewiseLexical,

		ShortestFloat: cbor.ShortestFloat16,

		NaNConvert: cbor.NaNConvert7e00,
		InfConvert: cbor.InfConvertFloat16,

		BigIntConvert: cbor.BigIntConvertShortest,

		Time: cbor.TimeRFC3339Nano,

		TimeTag: cbor.EncTagNone,

		IndefLength: cbor.IndefLengthForbidden,

		NilContainers: cbor.NilContainerAsNull,

		TagsMd: cbor.TagsAllowed,

		OmitEmpty: cbor.OmitEmptyGoValue,

		String: cbor.StringToByteString,

		FieldName: cbor.FieldNameToByteString,
	}.EncMode()
	if err != nil {
		panic(err)
	}
	return encode
}()
View Source
var EncodeNondeterministic cbor.EncMode = func() cbor.EncMode {
	opts := Encode.EncOptions()
	opts.Sort = cbor.SortNone
	em, err := opts.EncMode()
	if err != nil {
		panic(err)
	}
	return em
}()

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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