Documentation ¶
Index ¶
- Constants
- Variables
- func CborEncodeMajorType(t byte, l uint64) []byte
- func CborReadHeader(br io.Reader) (byte, uint64, int, error)
- func CborReadHeaderBuf(br io.Reader, scratch []byte) (byte, uint64, int, error)
- func CborWriteHeader(w io.Writer, t byte, l uint64) (n int, err error)
- func EncodeBool(b bool) []byte
- func GenMapEncodersForType(gti *GenTypeInfo, flattenEmbeddedStruct bool, ...) error
- func GenTupleEncodersForType(gti *GenTypeInfo, flattenEmbeddedStruct bool, ...) error
- func MapKeySort_RFC7049(keys []string)
- func PrintHeaderAndUtilityMethods(w io.Writer, pkg string, typeInfos []*GenTypeInfo) error
- func ReadByteArray(br io.Reader, maxlen uint64) ([]byte, int, error)
- func ReadCid(br io.Reader) (cid.Cid, int, error)
- func ReadString(r io.Reader) (string, int, error)
- func ReadStringBuf(r io.Reader, scratch []byte) (string, int, error)
- func ReadTaggedByteArray(br io.Reader, exptag uint64, maxlen uint64) ([]byte, int, error)
- func ScanForLinks(br io.Reader, cb func(cid.Cid)) (int, error)
- func ValidateCBOR(b []byte) error
- func WriteBool(w io.Writer, b bool) (n int, err error)
- func WriteCid(w io.Writer, c cid.Cid) (n int, err error)
- func WriteCidBuf(buf []byte, w io.Writer, c cid.Cid) (n int, er error)
- func WriteMajorTypeHeader(w io.Writer, t byte, l uint64) (n int, err error)
- func WriteMajorTypeHeaderBuf(buf []byte, w io.Writer, t byte, l uint64) (n int, err error)
- func WriteMapEncodersToFile(fname, pkg string, flattenEmbeddedStruct bool, types ...interface{}) error
- func WriteTupleEncodersToFile(fname, pkg string, flattenEmbeddedStruct bool, fieldOrder []string, ...) error
- type BytePeeker
- type CBORMarshaler
- type CBORUnmarshaler
- type CborBool
- type CborCid
- type CborInt
- type CborTime
- type Deferred
- type Field
- type GenTypeInfo
- type Import
- type Initter
Constants ¶
const ( MajUnsignedInt = 0 MajNegativeInt = 1 MajByteString = 2 MajTextString = 3 MajArray = 4 MajMap = 5 MajTag = 6 MajOther = 7 )
const ByteArrayMaxLen = 2 << 20
const MaxLength = 8192
Variables ¶
var ( CborBoolFalse = []byte{0xf4} CborBoolTrue = []byte{0xf5} CborNull = []byte{0xf6} )
Functions ¶
func CborEncodeMajorType ¶
func CborReadHeaderBuf ¶
same as the above, just tries to allocate less by using a passed in scratch buffer
func EncodeBool ¶
func GenMapEncodersForType ¶
func GenMapEncodersForType(gti *GenTypeInfo, flattenEmbeddedStruct bool, embeddedByPointerStructs *[]string, w io.Writer) error
Generates 'tuple representation' cbor encoders for the given type
func GenTupleEncodersForType ¶
func GenTupleEncodersForType(gti *GenTypeInfo, flattenEmbeddedStruct bool, embeddedByPointerStructs *[]string, w io.Writer) error
Generates 'tuple representation' cbor encoders for the given type
func MapKeySort_RFC7049 ¶
func MapKeySort_RFC7049(keys []string)
func PrintHeaderAndUtilityMethods ¶
func PrintHeaderAndUtilityMethods(w io.Writer, pkg string, typeInfos []*GenTypeInfo) error
func ReadTaggedByteArray ¶
func ValidateCBOR ¶
ValidateCBOR validates that a byte array is a single valid CBOR object.
func WriteMajorTypeHeader ¶
TODO: No matter what I do, this function *still* allocates. Its super frustrating. See issue: https://github.com/golang/go/issues/33160
func WriteMajorTypeHeaderBuf ¶
Same as the above, but uses a passed in buffer to avoid allocations
func WriteMapEncodersToFile ¶
func WriteMapEncodersToFile(fname, pkg string, flattenEmbeddedStruct bool, types ...interface{}) error
WriteMapFileEncodersToFile generates map backed MarshalCBOR and UnmarshalCBOR implementations for the given types in the specified file, with the specified package name.
The MarshalCBOR and UnmarshalCBOR implementations will marshal/unmarshal each type's fields as a map of field names to field values.
func WriteTupleEncodersToFile ¶
func WriteTupleEncodersToFile(fname, pkg string, flattenEmbeddedStruct bool, fieldOrder []string, types ...interface{}) error
WriteTupleFileEncodersToFile generates array backed MarshalCBOR and UnmarshalCBOR implementations for the given types in the specified file, with the specified package name.
The MarshalCBOR and UnmarshalCBOR implementations will marshal/unmarshal each type's fields as a fixed-length CBOR array of field values.
Types ¶
type BytePeeker ¶
type BytePeeker interface { io.Reader io.ByteScanner }
BytePeeker combines the Reader and ByteScanner interfaces.
func GetPeeker ¶
func GetPeeker(r io.Reader) BytePeeker
type CBORMarshaler ¶
type CBORUnmarshaler ¶
type Field ¶
type GenTypeInfo ¶
func ParseTypeInfo ¶
func ParseTypeInfo(i interface{}, flattenEmbeddedStruct bool) ( gti *GenTypeInfo, embeddedByPointerStructs *[]string, err error)
func (*GenTypeInfo) Imports ¶
func (gti *GenTypeInfo) Imports() []Import
func (GenTypeInfo) MapHeader ¶
func (gti GenTypeInfo) MapHeader() []byte
func (GenTypeInfo) MapHeaderAsByteString ¶
func (gti GenTypeInfo) MapHeaderAsByteString() string
func (*GenTypeInfo) NeedsScratch ¶
func (gti *GenTypeInfo) NeedsScratch() bool
func (GenTypeInfo) TupleHeader ¶
func (gti GenTypeInfo) TupleHeader() []byte
func (GenTypeInfo) TupleHeaderAsByteString ¶
func (gti GenTypeInfo) TupleHeaderAsByteString() string