Documentation
¶
Index ¶
- func Marshal(v interface{}) ([]byte, error)
- type AddMapItemFunc
- type Builder
- func (b *Builder) AddArray(n uint64, fn BuilderContinuation)
- func (b *Builder) AddBool(v bool)
- func (b *Builder) AddBytes(v []byte)
- func (b *Builder) AddBytesUnknownLength(fn BuilderContinuation)
- func (b *Builder) AddFloat32(v float32)
- func (b *Builder) AddFloat64(v float64)
- func (b *Builder) AddInt(v int)
- func (b *Builder) AddInt8(v int8)
- func (b *Builder) AddInt16(v int16)
- func (b *Builder) AddInt32(v int32)
- func (b *Builder) AddInt64(v int64)
- func (b *Builder) AddMap(length int)
- func (b *Builder) AddMapItem(k, v BuilderContinuation)
- func (b *Builder) AddNil()
- func (b *Builder) AddRawBytes(v []byte)
- func (b *Builder) AddString(v string)
- func (b *Builder) AddTag(number uint64)
- func (b *Builder) AddUint(v uint)
- func (b *Builder) AddUint8(v uint8)
- func (b *Builder) AddUint16(v uint16)
- func (b *Builder) AddUint32(v uint32)
- func (b *Builder) AddUint64(v uint64)
- func (b *Builder) AddValue(v MarshalingValue)
- func (b *Builder) Bytes() ([]byte, error)
- func (b *Builder) Len() int
- func (b *Builder) Marshal(v interface{})
- func (b *Builder) SetError(err error)
- type BuilderContinuation
- type MarshalingValue
- type ModeFloat
- type ModeInf
- type ModeNaN
- type ModeSort
- type RawBytes
- type RawTag
- type Tag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AddMapItemFunc ¶
type AddMapItemFunc func(fnkey, fnvalue BuilderContinuation)
type Builder ¶
type Builder struct {
ModeNaN ModeNaN
ModeInf ModeInf
ModeFloat ModeFloat
ModeSort ModeSort
// contains filtered or unexported fields
}
func NewBuilder ¶
func (*Builder) AddArray ¶
func (b *Builder) AddArray(n uint64, fn BuilderContinuation)
func (*Builder) AddBytesUnknownLength ¶
func (b *Builder) AddBytesUnknownLength(fn BuilderContinuation)
func (*Builder) AddFloat32 ¶
func (*Builder) AddFloat64 ¶
func (*Builder) AddMapItem ¶
func (b *Builder) AddMapItem(k, v BuilderContinuation)
func (*Builder) AddRawBytes ¶
func (*Builder) AddValue ¶
func (b *Builder) AddValue(v MarshalingValue)
AddValue calls MarshalCBORValue on v, passing a pointer to the builder to append to. If MarshalCBORValue returns an error, it is set on the Builder so that subsequent appends don't have an effect.
type BuilderContinuation ¶
type BuilderContinuation func(*Builder)
BuilderContinuation is a continuation-passing interface for building length-prefixed byte sequences.
type MarshalingValue ¶
A MarshalingValue marshals itself into a Builder.
type ModeFloat ¶
type ModeFloat int
ModeFloat specifies which floating-point format should be used as the shortest possible format for CBOR encoding. It is not used for encoding Infinity and NaN values.
const ( // ModeFloat16 specifies float16 as the shortest form that preserves value. // E.g. if float64 can convert to float32 while preserving value, then // encoding will also try to convert float32 to float16. So a float64 might // encode as CBOR float64, float32 or float16 depending on the value. ModeFloat16 ModeFloat = iota // ModeFloatNone makes float values encode without any conversion. // E.g. a float32 in Go will encode to CBOR float32. And // a float64 in Go will encode to CBOR float64. ModeFloatNone )
type ModeInf ¶
type ModeInf int
ModeInf specifies how to encode Infinity and overrides ModeFloat. ModeFloat is not used for encoding Infinity and NaN values.
type ModeSort ¶
type ModeSort int
ModeSort identifies supported sorting order.
const ( // ModeSortLengthFirst causes map keys or struct fields to be sorted such that: // - If two keys have different lengths, the shorter one sorts earlier; // - If two keys have the same length, the one with the lower value in // (byte-wise) lexical order sorts earlier. // It is used in "Canonical CBOR" encoding in RFC 7049 3.9. ModeSortLengthFirst ModeSort = iota // ModeSortBytewiseLexical causes map keys or struct fields to be sorted in the // bytewise lexicographic order of their deterministic CBOR encodings. // It is used in "CTAP2 Canonical CBOR" and "Core Deterministic Encoding" // in RFC 7049bis. ModeSortBytewiseLexical // ModeSortNone means no sorting. ModeSortNone )