Documentation ¶
Index ¶
- Constants
- Variables
- func CborEncodeMajorType(t byte, l uint64) []byte
- func CborReadHeader(br io.Reader) (byte, uint64, error)
- func CborReadHeaderBuf(br io.Reader, scratch []byte) (byte, uint64, error)
- func CborWriteHeader(w io.Writer, t byte, l uint64) error
- func EncodeBool(b bool) []byte
- func GenMapEncodersForType(gti *GenTypeInfo, w io.Writer) error
- func GenTupleEncodersForType(gti *GenTypeInfo, w io.Writer) error
- func PrintHeaderAndUtilityMethods(w io.Writer, pkg string, typeInfos []*GenTypeInfo) error
- func ReadByteArray(br io.Reader, maxlen uint64) ([]byte, error)
- func ReadCid(br io.Reader) (cid.Cid, error)
- func ReadString(r io.Reader) (string, error)
- func ReadStringBuf(r io.Reader, scratch []byte) (string, error)
- func ReadTaggedByteArray(br io.Reader, exptag uint64, maxlen uint64) ([]byte, error)
- func ScanForLinks(br io.Reader, cb func(cid.Cid)) error
- func ValidateCBOR(b []byte) error
- func WriteBool(w io.Writer, b bool) error
- func WriteCid(w io.Writer, c cid.Cid) error
- func WriteCidBuf(buf []byte, w io.Writer, c cid.Cid) error
- func WriteMajorTypeHeader(w io.Writer, t byte, l uint64) error
- func WriteMajorTypeHeaderBuf(buf []byte, w io.Writer, t byte, l uint64) error
- func WriteMapEncodersToFile(fname, pkg string, types ...interface{}) error
- func WriteTupleEncodersToFile(fname, pkg string, types ...interface{}) error
- type BytePeeker
- type CBORMarshaler
- type CBORUnmarshaler
- type CborBool
- type CborCid
- type CborInt
- type CborTime
- type Deferred
- type Field
- type GenTypeInfo
- type Import
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, w io.Writer) error
Generates 'tuple representation' cbor encoders for the given type
func GenTupleEncodersForType ¶
func GenTupleEncodersForType(gti *GenTypeInfo, w io.Writer) error
Generates 'tuple representation' cbor encoders for the given type
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 ¶
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 ¶
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 GenTypeInfo ¶
func ParseTypeInfo ¶
func ParseTypeInfo(i interface{}) (*GenTypeInfo, 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