Documentation ¶
Index ¶
- Constants
- Variables
- func Marshal(v any) ([]byte, error)
- func Unmarshal(b []byte, v any) error
- type Decoder
- func (d *Decoder) Decode(v any) error
- func (d *Decoder) DecodeBool() (bool, error)
- func (d *Decoder) DecodeBytes() ([]byte, error)
- func (d *Decoder) DecodeFloat() (float64, error)
- func (d *Decoder) DecodeHash() ([32]byte, error)
- func (d *Decoder) DecodeInt() (int64, error)
- func (d *Decoder) DecodeString() (string, error)
- func (d *Decoder) DecodeUint() (uint64, error)
- func (d *Decoder) DecodeValue(v encoding.BinaryUnmarshaler) error
- func (d *Decoder) DecodeValueV2(v Unmarshaller) error
- func (d *Decoder) EndObject() error
- func (d *Decoder) Field() (uint, error)
- func (d *Decoder) InField() bool
- func (s *Decoder) Pool() *Pool
- func (d *Decoder) StartObject() error
- type Encoder
- func (e *Encoder) Context() *traverse.Context[reflect.Value]
- func (e *Encoder) Done() error
- func (e *Encoder) Encode(v any) error
- func (e *Encoder) EncodeBool(v bool) error
- func (e *Encoder) EncodeBytes(v []byte) error
- func (e *Encoder) EncodeField(n uint, v any) error
- func (e *Encoder) EncodeFloat(v float64) error
- func (e *Encoder) EncodeHash(v *[32]byte) error
- func (e *Encoder) EncodeInt(v int64) error
- func (e *Encoder) EncodeString(v string) error
- func (e *Encoder) EncodeUint(v uint64) error
- func (e *Encoder) EncodeValue(v encoding.BinaryMarshaler) error
- func (e *Encoder) EncodeValueV2(v Marshaller) error
- func (e *Encoder) EndObject() error
- func (e *Encoder) Field(n uint) error
- func (e *Encoder) InField() bool
- func (e *Encoder) Pool() *Pool
- func (e *Encoder) RepeatLastField() error
- func (e *Encoder) Reset(w io.Writer, opts ...Option)
- func (e *Encoder) StartObject() error
- type Marshaller
- type Option
- type Pool
- type Unmarshaller
Constants ¶
View Source
const EmptyObject = 0x80
EmptyObject is written when an object would otherwise be empty.
Variables ¶
View Source
var ErrFieldsOutOfOrder = errors.New("fields are out of order")
ErrFieldsOutOfOrder is returned when an out of order field is encountered.
View Source
var ErrInvalidFieldNumber = errors.New("field number is invalid")
ErrInvalidFieldNumber is returned when an invalid field number is encountered.
Functions ¶
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func (*Decoder) DecodeBool ¶
func (*Decoder) DecodeBytes ¶
func (*Decoder) DecodeFloat ¶
func (*Decoder) DecodeHash ¶
func (*Decoder) DecodeString ¶
func (*Decoder) DecodeUint ¶
func (*Decoder) DecodeValue ¶
func (d *Decoder) DecodeValue(v encoding.BinaryUnmarshaler) error
func (*Decoder) DecodeValueV2 ¶
func (d *Decoder) DecodeValueV2(v Unmarshaller) error
func (*Decoder) InField ¶
InField returns true if the decoder just read a field ID.
This is a hack and somewhat exposes the internal state of the decoder, but I can't think of a cleaner way of handling arrays (given that changing the encoding isn't an option).
func (*Decoder) StartObject ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
func (*Encoder) EncodeBool ¶
func (*Encoder) EncodeBytes ¶
func (*Encoder) EncodeFloat ¶
func (*Encoder) EncodeHash ¶
func (*Encoder) EncodeString ¶
func (*Encoder) EncodeUint ¶
func (*Encoder) EncodeValue ¶
func (e *Encoder) EncodeValue(v encoding.BinaryMarshaler) error
func (*Encoder) EncodeValueV2 ¶
func (e *Encoder) EncodeValueV2(v Marshaller) error
func (*Encoder) InField ¶
InField returns true if the decoder just read a field ID.
This is a hack and somewhat exposes the internal state of the decoder, but I can't think of a cleaner way of handling arrays (given that changing the encoding isn't an option).
func (*Encoder) RepeatLastField ¶
func (*Encoder) StartObject ¶
type Marshaller ¶
type Unmarshaller ¶
Click to show internal directories.
Click to hide internal directories.