cbor

package
v0.0.0-...-144e09d Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagStandardDateTimeString      TagSmall = 0
	TagEpochDateTimeNumber         TagSmall = 1
	TagExpectConversionToBase64Url TagSmall = 21
	TagExpectConversionToBase64Std TagSmall = 22
	TagExpectConversionToHex       TagSmall = 23

	TagEncodedCBORDataItem        TagUint8 = 24
	TagReferenceNthPreviousString TagUint8 = 25
	TagURIValue                   TagUint8 = 32
	TagBase64Url                  TagUint8 = 33
	TagBase64Std                  TagUint8 = 34
	TagRegexp                     TagUint8 = 35
	TagBinaryUUID                 TagUint8 = 37
	TagMultiDimArrayRowMajor      TagUint8 = 40
	TagHomogenousArray            TagUint8 = 41
	TagIPv4                       TagUint8 = 52
	TagIPv6                       TagUint8 = 54
	TagEncodedCBORSequence        TagUint8 = 63
	TagTypedArrayUint8            TagUint8 = 64
	TagTypedArrayUint16BE         TagUint8 = 65
	TagTypedArrayUint32BE         TagUint8 = 66
	TagTypedArrayUint64BE         TagUint8 = 67
	TagTypedArrayUint8Clamped     TagUint8 = 68
	TagTypedArrayUint16LE         TagUint8 = 69
	TagTypedArrayUint32LE         TagUint8 = 70
	TagTypedArrayUint64LE         TagUint8 = 71
	TagTypedArraySint8            TagUint8 = 72
	TagTypedArraySint16BE         TagUint8 = 73
	TagTypedArraySint32BE         TagUint8 = 74
	TagTypedArraySint64BE         TagUint8 = 75
	TagTypedArraySint16LE         TagUint8 = 77
	TagTypedArraySint32LE         TagUint8 = 78
	TagTypedArraySint64LE         TagUint8 = 79
	TagTypedArrayFloat16BE        TagUint8 = 80
	TagTypedArrayFloat32BE        TagUint8 = 81
	TagTypedArrayFloat64BE        TagUint8 = 82
	TagTypedArrayFloat128BE       TagUint8 = 83
	TagTypedArrayFloat16LE        TagUint8 = 84
	TagTypedArrayFloat32LE        TagUint8 = 85
	TagTypedArrayFloat64LE        TagUint8 = 86
	TagTypedArrayFloat128LE       TagUint8 = 87
	TagTextMimeMessage            TagUint8 = 36

	TagBinaryMimeMessage        TagUint16 = 257
	TagMathematicalFiniteSet    TagUint16 = 258
	TagEmbeddedJSON             TagUint16 = 262
	TagHexString                TagUint16 = 263
	TagMapStringKeysOnly        TagUint16 = 275
	TagMultiDimArrayColumnMajor TagUint16 = 1040
	TagSelfDescribedCBOR        TagUint16 = 55799
	TagFileContainsCBORSeq      TagUint16 = 55800
)
View Source
const MaxTagSmallIncl uint8 = 23

Variables

View Source
var ErrNoHasher = eh.Errorf("no hasher")

Functions

This section is empty.

Types

type CborPayloadEncoder

type CborPayloadEncoder interface {
	EncodeCborPayload(val []byte) (int, error)
}

type DefiniteContainerEncoder

type DefiniteContainerEncoder interface {
	EncodeArrayDefinite(length uint64) (int, error)
	EncodeMapDefinite(length uint64) (int, error)
}

type Encoder

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

func NewEncoder

func NewEncoder(w EncoderWriter, hasher hash.Hash) *Encoder

func (*Encoder) EncodeArrayDefinite

func (inst *Encoder) EncodeArrayDefinite(length uint64) (n int, err error)

func (*Encoder) EncodeArrayIndefinite

func (inst *Encoder) EncodeArrayIndefinite() (n int, err error)

func (*Encoder) EncodeBool

func (inst *Encoder) EncodeBool(val bool) (n int, err error)

func (*Encoder) EncodeBreak

func (inst *Encoder) EncodeBreak() (n int, err error)

func (*Encoder) EncodeByteSlice

func (inst *Encoder) EncodeByteSlice(b []byte) (n int, err error)

func (*Encoder) EncodeCborPayload

func (inst *Encoder) EncodeCborPayload(val []byte) (n int, err error)

func (*Encoder) EncodeFloat32

func (inst *Encoder) EncodeFloat32(val float32) (n int, err error)

func (*Encoder) EncodeFloat64

func (inst *Encoder) EncodeFloat64(val float64) (n int, err error)

func (*Encoder) EncodeInt

func (inst *Encoder) EncodeInt(val int64) (int, error)

func (*Encoder) EncodeIpAddr

func (inst *Encoder) EncodeIpAddr(val netip.Addr) (n int, err error)

func (*Encoder) EncodeJsonPayload

func (inst *Encoder) EncodeJsonPayload(val []byte) (n int, err error)

func (*Encoder) EncodeMapDefinite

func (inst *Encoder) EncodeMapDefinite(length uint64) (n int, err error)

func (*Encoder) EncodeMapIndefinite

func (inst *Encoder) EncodeMapIndefinite() (n int, err error)

func (*Encoder) EncodeNil

func (inst *Encoder) EncodeNil() (n int, err error)

func (*Encoder) EncodeString

func (inst *Encoder) EncodeString(str string) (n int, err error)

func (*Encoder) EncodeTag16

func (inst *Encoder) EncodeTag16(val TagUint16) (int, error)

func (*Encoder) EncodeTag32

func (inst *Encoder) EncodeTag32(val TagUint32) (int, error)

func (*Encoder) EncodeTag64

func (inst *Encoder) EncodeTag64(val TagUint64) (int, error)

func (*Encoder) EncodeTag8

func (inst *Encoder) EncodeTag8(val TagUint8) (int, error)

func (*Encoder) EncodeTagSmall

func (inst *Encoder) EncodeTagSmall(val TagSmall) (int, error)

func (*Encoder) EncodeTimeUTC

func (inst *Encoder) EncodeTimeUTC(val time.Time) (n int, err error)

func (*Encoder) EncodeUint

func (inst *Encoder) EncodeUint(val uint64) (int, error)

func (*Encoder) Hash

func (inst *Encoder) Hash(b []byte) (hash []byte, err error)

func (*Encoder) Reset

func (inst *Encoder) Reset()

func (*Encoder) SetHasher

func (inst *Encoder) SetHasher(hasher hash.Hash)

func (*Encoder) SetWriter

func (inst *Encoder) SetWriter(w EncoderWriter)

func (*Encoder) TagUint16

func (inst *Encoder) TagUint16(val TagUint16) (int, error)

func (*Encoder) TagUint32

func (inst *Encoder) TagUint32(val TagUint32) (int, error)

func (*Encoder) TagUint64

func (inst *Encoder) TagUint64(val TagUint64) (int, error)

type EncoderWriter

type EncoderWriter interface {
	io.ByteWriter
	io.Writer
	io.StringWriter
}

type Generator

type Generator struct {
	MaxNestingLevel    int
	Hasher             hash.Hash64
	Enc                *Encoder
	MaxTotalPrimitives int
	// contains filtered or unexported fields
}

func NewGenerator

func NewGenerator(w EncoderWriter, randSeed int64) *Generator

func (*Generator) GenerateRandomCbor

func (inst *Generator) GenerateRandomCbor() (n int, err error)

func (*Generator) GenerateRandomCborScalar

func (inst *Generator) GenerateRandomCborScalar() (n int, err error)

func (*Generator) Reset

func (inst *Generator) Reset()

func (*Generator) SetMaxStringLength

func (inst *Generator) SetMaxStringLength(n int)

type HashingEncoder

type HashingEncoder interface {
	Hash(sum []byte) ([]byte, error)
	SetHasher(hasher hash.Hash)
}

type IndefiniteContainerEncoder

type IndefiniteContainerEncoder interface {
	EncodeMapIndefinite() (int, error)
	EncodeArrayIndefinite() (int, error)
	EncodeBreak() (int, error)
}

type MajorType

type MajorType uint8
const MajorTypeArray MajorType = 4
const MajorTypeByteString MajorType = 2
const MajorTypeFloatOrSimple MajorType = 7
const MajorTypeMap MajorType = 5
const MajorTypeNegativeInt MajorType = 1
const MajorTypePositiveInt MajorType = 0
const MajorTypeTag MajorType = 6
const MajorTypeUtf8String MajorType = 3

type PrimitiveEncoder

type PrimitiveEncoder interface {
	EncodeUint(val uint64) (int, error)
	EncodeInt(val int64) (int, error)
	EncodeByteSlice(val []byte) (int, error)
	EncodeString(val string) (int, error)
	EncodeBool(val bool) (int, error)
	EncodeFloat32(val float32) (int, error)
	EncodeFloat64(val float64) (int, error)
	EncodeTimeUTC(val time.Time) (int, error)
	EncodeNil() (int, error)
}

type ResetableEncoder

type ResetableEncoder interface {
	Reset()
	SetWriter(dest EncoderWriter)
}

type TagEncoder

type TagEncoder interface {
	EncodeTagSmall(tagSmall TagSmall) (int, error)
	EncodeTag8(tagUint8 TagUint8) (int, error)
	EncodeTag16(tagUint16 TagUint16) (int, error)
	EncodeTag32(tagUint32 TagUint32) (int, error)
	EncodeTag64(tagUint64 TagUint64) (int, error)
}

type TagSmall

type TagSmall uint8

type TagUint16

type TagUint16 uint16

type TagUint32

type TagUint32 uint32

type TagUint64

type TagUint64 uint64

type TagUint8

type TagUint8 uint8

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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