Documentation ¶
Index ¶
- Constants
- Variables
- func AnyFromJSON(v interface{}) (interface{}, error)
- func AnyToJSON(v interface{}) interface{}
- func BigintCopy(v *big.Int) *big.Int
- func BigintFromJSON(s *string) (*big.Int, error)
- func BigintToJSON(b *big.Int) *string
- func BytesCopy(v []byte) []byte
- func BytesFromJSON(s *string) ([]byte, error)
- func BytesToJSON(v []byte) *string
- func Cast[U, V any](v V, err error) (U, error)
- func ChainFromJSON(s string) ([32]byte, error)
- func ChainToJSON(v [32]byte) string
- func Copy[T any, PT interface{ ... }](m *Machine[PT], v PT) PT
- func DurationFromJSON(v interface{}) (time.Duration, error)
- func DurationToJSON(v time.Duration) interface{}
- func Hash(m BinaryValue) [32]byte
- func MarshalBytes(v []byte) []byte
- func MarshalHash(v *[32]byte) []byte
- func MarshalInt(v int64) []byte
- func MarshalString(s string) []byte
- func MarshalUint(v uint64) []byte
- func SetPtr(value, target interface{}) (err error)
- func SplitDuration(d time.Duration) (sec, ns uint64)
- func UnmarshalBytes(b []byte) ([]byte, error)
- func UnmarshalHash(b []byte) ([32]byte, error)
- func UnmarshalInt(b []byte) (int64, error)
- func UnmarshalString(b []byte) (string, error)
- func UnmarshalUint(b []byte) (uint64, error)
- type Accessor
- type BigIntField
- func (f BigIntField[V]) CopyTo(dst, src V)
- func (f BigIntField[V]) Equal(v, u V) bool
- func (f BigIntField[V]) FromJSON(b []byte, v V) error
- func (f BigIntField[V]) IsEmpty(v V) bool
- func (f BigIntField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f BigIntField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f BigIntField[V]) WriteTo(w *Writer, n uint, v V)
- type BigIntPtrField
- func (f BigIntPtrField[V]) CopyTo(dst, src V)
- func (f BigIntPtrField[V]) Equal(v, u V) bool
- func (f BigIntPtrField[V]) FromJSON(b []byte, v V) error
- func (f BigIntPtrField[V]) IsEmpty(v V) bool
- func (f BigIntPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f BigIntPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f BigIntPtrField[V]) WriteTo(w *Writer, n uint, v V)
- type BinaryValue
- type BoolField
- func (f BoolField[V]) CopyTo(dst, src V)
- func (f BoolField[V]) Equal(v, u V) bool
- func (f BoolField[V]) FromJSON(b []byte, v V) error
- func (f BoolField[V]) IsEmpty(v V) bool
- func (f BoolField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f BoolField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f BoolField[V]) WriteTo(w *Writer, n uint, v V)
- type BoolPtrField
- func (f BoolPtrField[V]) CopyTo(dst, src V)
- func (f BoolPtrField[V]) Equal(v, u V) bool
- func (f BoolPtrField[V]) FromJSON(b []byte, v V) error
- func (f BoolPtrField[V]) IsEmpty(v V) bool
- func (f BoolPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f BoolPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f BoolPtrField[V]) WriteTo(w *Writer, n uint, v V)
- type BytesField
- func (f BytesField[V]) CopyTo(dst, src V)
- func (f BytesField[V]) Equal(v, u V) bool
- func (f BytesField[V]) FromJSON(b []byte, v V) error
- func (f BytesField[V]) IsEmpty(v V) bool
- func (f BytesField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f BytesField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f BytesField[V]) WriteTo(w *Writer, n uint, v V)
- type BytesPtrField
- func (f BytesPtrField[V]) CopyTo(dst, src V)
- func (f BytesPtrField[V]) Equal(v, u V) bool
- func (f BytesPtrField[V]) FromJSON(b []byte, v V) error
- func (f BytesPtrField[V]) IsEmpty(v V) bool
- func (f BytesPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f BytesPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f BytesPtrField[V]) WriteTo(w *Writer, n uint, v V)
- type BytesReader
- type DurationField
- func (f DurationField[V]) CopyTo(dst, src V)
- func (f DurationField[V]) Equal(v, u V) bool
- func (f DurationField[V]) FromJSON(b []byte, v V) error
- func (f DurationField[V]) IsEmpty(v V) bool
- func (f DurationField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f DurationField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f DurationField[V]) WriteTo(w *Writer, n uint, v V)
- type DurationFields
- type DurationPtrField
- func (f DurationPtrField[V]) CopyTo(dst, src V)
- func (f DurationPtrField[V]) Equal(v, u V) bool
- func (f DurationPtrField[V]) FromJSON(b []byte, v V) error
- func (f DurationPtrField[V]) IsEmpty(v V) bool
- func (f DurationPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f DurationPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f DurationPtrField[V]) WriteTo(w *Writer, n uint, v V)
- type EnumField
- func (f EnumField[V, U, W]) CopyTo(dst, src V)
- func (f EnumField[V, U, W]) Equal(v, u V) bool
- func (f EnumField[V, U, W]) FromJSON(b []byte, v V) error
- func (f EnumField[V, U, W]) IsEmpty(v V) bool
- func (f EnumField[V, U, W]) ReadFrom(r *Reader, n uint, v V) bool
- func (f EnumField[V, U, W]) ToJSON(w *bytes.Buffer, v V) error
- func (f EnumField[V, U, W]) WriteTo(w *Writer, n uint, v V)
- type EnumPtrField
- func (f EnumPtrField[V, U, W]) CopyTo(dst, src V)
- func (f EnumPtrField[V, U, W]) Equal(v, u V) bool
- func (f EnumPtrField[V, U, W]) FromJSON(b []byte, v V) error
- func (f EnumPtrField[V, U, W]) IsEmpty(v V) bool
- func (f EnumPtrField[V, U, W]) ReadFrom(r *Reader, n uint, v V) bool
- func (f EnumPtrField[V, U, W]) ToJSON(w *bytes.Buffer, v V) error
- func (f EnumPtrField[V, U, W]) WriteTo(w *Writer, n uint, v V)
- type EnumValueGetter
- type EnumValueSetter
- type Error
- type Field
- type FloatField
- func (f FloatField[V]) CopyTo(dst, src V)
- func (f FloatField[V]) Equal(v, u V) bool
- func (f FloatField[V]) FromJSON(b []byte, v V) error
- func (f FloatField[V]) IsEmpty(v V) bool
- func (f FloatField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f FloatField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f FloatField[V]) WriteTo(w *Writer, n uint, v V)
- type FloatPtrField
- func (f FloatPtrField[V]) CopyTo(dst, src V)
- func (f FloatPtrField[V]) Equal(v, u V) bool
- func (f FloatPtrField[V]) FromJSON(b []byte, v V) error
- func (f FloatPtrField[V]) IsEmpty(v V) bool
- func (f FloatPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f FloatPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f FloatPtrField[V]) WriteTo(w *Writer, n uint, v V)
- type HashField
- func (f HashField[V]) CopyTo(dst, src V)
- func (f HashField[V]) Equal(v, u V) bool
- func (f HashField[V]) FromJSON(b []byte, v V) error
- func (f HashField[V]) IsEmpty(v V) bool
- func (f HashField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f HashField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f HashField[V]) WriteTo(w *Writer, n uint, v V)
- type HashPtrField
- func (f HashPtrField[V]) CopyTo(dst, src V)
- func (f HashPtrField[V]) Equal(v, u V) bool
- func (f HashPtrField[V]) FromJSON(b []byte, v V) error
- func (f HashPtrField[V]) IsEmpty(v V) bool
- func (f HashPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f HashPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f HashPtrField[V]) WriteTo(w *Writer, n uint, v V)
- type IntField
- func (f IntField[V]) CopyTo(dst, src V)
- func (f IntField[V]) Equal(v, u V) bool
- func (f IntField[V]) FromJSON(b []byte, v V) error
- func (f IntField[V]) IsEmpty(v V) bool
- func (f IntField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f IntField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f IntField[V]) WriteTo(w *Writer, n uint, v V)
- type IntPtrField
- func (f IntPtrField[V]) CopyTo(dst, src V)
- func (f IntPtrField[V]) Equal(v, u V) bool
- func (f IntPtrField[V]) FromJSON(b []byte, v V) error
- func (f IntPtrField[V]) IsEmpty(v V) bool
- func (f IntPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f IntPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f IntPtrField[V]) WriteTo(w *Writer, n uint, v V)
- type JsonList
- type JsonUnmarshalListWith
- type JsonUnmarshalWith
- type Machine
- func (m *Machine[T]) Equal(v, u T) bool
- func (m *Machine[T]) FromJSON(b []byte, v T) error
- func (m *Machine[T]) IsValid(v T) error
- func (m *Machine[T]) JSONMarshal(v T) ([]byte, error)
- func (m *Machine[T]) JSONUnmarshal(b []byte, v T) error
- func (m *Machine[T]) MarshalBinary(v T) ([]byte, error)
- func (m *Machine[T]) ReadFrom(r *Reader, v T)
- func (m *Machine[T]) ToJSON(w *bytes.Buffer, v T) error
- func (m *Machine[T]) Unmarshal(b []byte, v T) error
- func (m *Machine[T]) UnmarshalFrom(rd io.Reader, v T) error
- func (m *Machine[T]) WriteTo(w *Writer, v T)
- type ReadOnlyAccessor
- func (f ReadOnlyAccessor[V, U, A]) CopyTo(dst, src V)
- func (f ReadOnlyAccessor[V, U, A]) Equal(v, u V) bool
- func (f ReadOnlyAccessor[V, U, A]) FromJSON(b []byte, v V) error
- func (f ReadOnlyAccessor[V, U, A]) IsEmpty(v V) bool
- func (f ReadOnlyAccessor[V, U, A]) ReadFrom(r *Reader, n uint, v V) bool
- func (f ReadOnlyAccessor[V, U, A]) ToJSON(w *bytes.Buffer, v V) error
- func (f ReadOnlyAccessor[V, U, A]) WriteTo(w *Writer, n uint, v V)
- type Reader
- func (r *Reader) IsEmpty() bool
- func (r *Reader) ReadAll() ([]byte, error)
- func (r *Reader) ReadBigInt(n uint) (*big.Int, bool)
- func (r *Reader) ReadBool(n uint) (bool, bool)
- func (r *Reader) ReadBytes(n uint) ([]byte, bool)
- func (r *Reader) ReadDuration(n uint) (time.Duration, bool)
- func (r *Reader) ReadEnum(n uint, v EnumValueSetter) bool
- func (r *Reader) ReadFloat(n uint) (float64, bool)
- func (r *Reader) ReadHash(n uint) (*[32]byte, bool)
- func (r *Reader) ReadHash2(n uint) ([32]byte, bool)
- func (r *Reader) ReadInt(n uint) (int64, bool)
- func (r *Reader) ReadString(n uint) (string, bool)
- func (r *Reader) ReadTime(n uint) (time.Time, bool)
- func (r *Reader) ReadTxid(n uint) (*url.TxID, bool)
- func (r *Reader) ReadUint(n uint) (uint64, bool)
- func (r *Reader) ReadUrl(n uint) (*url.URL, bool)
- func (r *Reader) ReadValue(n uint, unmarshal func(io.Reader) error) bool
- func (r *Reader) Reset(fieldNames []string) (seen []bool, err error)
- type SliceField
- func (f SliceField[V, U, A]) CopyTo(dst, src V)
- func (f SliceField[V, U, A]) Equal(v, u V) bool
- func (f SliceField[V, U, A]) FromJSON(b []byte, v V) error
- func (f SliceField[V, U, A]) IsEmpty(v V) bool
- func (f SliceField[V, U, A]) ReadFrom(r *Reader, n uint, v V) bool
- func (f SliceField[V, U, A]) ToJSON(w *bytes.Buffer, v V) error
- func (f SliceField[V, U, A]) WriteTo(w *Writer, n uint, v V)
- type SliceIndex
- type StringField
- func (f StringField[V]) CopyTo(dst, src V)
- func (f StringField[V]) Equal(v, u V) bool
- func (f StringField[V]) FromJSON(b []byte, v V) error
- func (f StringField[V]) IsEmpty(v V) bool
- func (f StringField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f StringField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f StringField[V]) WriteTo(w *Writer, n uint, v V)
- type StringPtrField
- func (f StringPtrField[V]) CopyTo(dst, src V)
- func (f StringPtrField[V]) Equal(v, u V) bool
- func (f StringPtrField[V]) FromJSON(b []byte, v V) error
- func (f StringPtrField[V]) IsEmpty(v V) bool
- func (f StringPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f StringPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f StringPtrField[V]) WriteTo(w *Writer, n uint, v V)
- type StructField
- func (f StructField[V, U, W]) CopyTo(dst, src V)
- func (f StructField[V, U, W]) Equal(v, u V) bool
- func (f StructField[V, U, W]) FromJSON(b []byte, v V) error
- func (f StructField[V, U, W]) IsEmpty(v V) bool
- func (f StructField[V, U, W]) ReadFrom(r *Reader, n uint, v V) bool
- func (f StructField[V, U, W]) ToJSON(w *bytes.Buffer, v V) error
- func (f StructField[V, U, W]) WriteTo(w *Writer, n uint, v V)
- type StructPtrField
- func (f StructPtrField[V, U, W]) CopyTo(dst, src V)
- func (f StructPtrField[V, U, W]) Equal(v, u V) bool
- func (f StructPtrField[V, U, W]) FromJSON(b []byte, v V) error
- func (f StructPtrField[V, U, W]) IsEmpty(v V) bool
- func (f StructPtrField[V, U, W]) ReadFrom(r *Reader, n uint, v V) bool
- func (f StructPtrField[V, U, W]) ToJSON(w *bytes.Buffer, v V) error
- func (f StructPtrField[V, U, W]) WriteTo(w *Writer, n uint, v V)
- type TimeField
- func (f TimeField[V]) CopyTo(dst, src V)
- func (f TimeField[V]) Equal(v, u V) bool
- func (f TimeField[V]) FromJSON(b []byte, v V) error
- func (f TimeField[V]) IsEmpty(v V) bool
- func (f TimeField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f TimeField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f TimeField[V]) WriteTo(w *Writer, n uint, v V)
- type TimePtrField
- func (f TimePtrField[V]) CopyTo(dst, src V)
- func (f TimePtrField[V]) Equal(v, u V) bool
- func (f TimePtrField[V]) FromJSON(b []byte, v V) error
- func (f TimePtrField[V]) IsEmpty(v V) bool
- func (f TimePtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f TimePtrField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f TimePtrField[V]) WriteTo(w *Writer, n uint, v V)
- type TxIDField
- func (f TxIDField[V]) CopyTo(dst, src V)
- func (f TxIDField[V]) Equal(v, u V) bool
- func (f TxIDField[V]) FromJSON(b []byte, v V) error
- func (f TxIDField[V]) IsEmpty(v V) bool
- func (f TxIDField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f TxIDField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f TxIDField[V]) WriteTo(w *Writer, n uint, v V)
- type TxIDPtrField
- func (f TxIDPtrField[V]) CopyTo(dst, src V)
- func (f TxIDPtrField[V]) Equal(v, u V) bool
- func (f TxIDPtrField[V]) FromJSON(b []byte, v V) error
- func (f TxIDPtrField[V]) IsEmpty(v V) bool
- func (f TxIDPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f TxIDPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f TxIDPtrField[V]) WriteTo(w *Writer, n uint, v V)
- type UintField
- func (f UintField[V]) CopyTo(dst, src V)
- func (f UintField[V]) Equal(v, u V) bool
- func (f UintField[V]) FromJSON(b []byte, v V) error
- func (f UintField[V]) IsEmpty(v V) bool
- func (f UintField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f UintField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f UintField[V]) WriteTo(w *Writer, n uint, v V)
- type UintPtrField
- func (f UintPtrField[V]) CopyTo(dst, src V)
- func (f UintPtrField[V]) Equal(v, u V) bool
- func (f UintPtrField[V]) FromJSON(b []byte, v V) error
- func (f UintPtrField[V]) IsEmpty(v V) bool
- func (f UintPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f UintPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f UintPtrField[V]) WriteTo(w *Writer, n uint, v V)
- type UnionRegistry
- func (r *UnionRegistry[T, V]) Equal(u, v V) bool
- func (r *UnionRegistry[T, V]) New(typ T) (V, bool)
- func (r *UnionRegistry[T, V]) Register(str string, new func() V, equal func(V, V) bool) error
- func (r *UnionRegistry[T, V]) TypeByName(s string) (T, bool)
- func (r *UnionRegistry[T, V]) TypeByValue(v uint64) (T, bool)
- func (r *UnionRegistry[T, V]) TypeName(typ T) (string, bool)
- type UnionValue
- type UrlField
- func (f UrlField[V]) CopyTo(dst, src V)
- func (f UrlField[V]) Equal(v, u V) bool
- func (f UrlField[V]) FromJSON(b []byte, v V) error
- func (f UrlField[V]) IsEmpty(v V) bool
- func (f UrlField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f UrlField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f UrlField[V]) WriteTo(w *Writer, n uint, v V)
- type UrlPtrField
- func (f UrlPtrField[V]) CopyTo(dst, src V)
- func (f UrlPtrField[V]) Equal(v, u V) bool
- func (f UrlPtrField[V]) FromJSON(b []byte, v V) error
- func (f UrlPtrField[V]) IsEmpty(v V) bool
- func (f UrlPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
- func (f UrlPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
- func (f UrlPtrField[V]) WriteTo(w *Writer, n uint, v V)
- type Writer
- func (w *Writer) Reset(fieldNames []string) (written int, lastField uint, err error)
- func (w *Writer) WriteBigInt(n uint, v *big.Int)
- func (w *Writer) WriteBool(n uint, v bool)
- func (w *Writer) WriteBytes(n uint, v []byte)
- func (w *Writer) WriteDuration(n uint, v time.Duration)
- func (w *Writer) WriteEnum(n uint, v EnumValueGetter)
- func (w *Writer) WriteFloat(n uint, v float64)
- func (w *Writer) WriteHash(n uint, v *[32]byte)
- func (w *Writer) WriteInt(n uint, v int64)
- func (w *Writer) WriteString(n uint, v string)
- func (w *Writer) WriteTime(n uint, v time.Time)
- func (w *Writer) WriteTxid(n uint, v *url.TxID)
- func (w *Writer) WriteUint(n uint, v uint64)
- func (w *Writer) WriteUrl(n uint, v *url.URL)
- func (w *Writer) WriteValue(n uint, marshal func() ([]byte, error))
Constants ¶
const EmptyObject = 0x80
EmptyObject is written when an object would otherwise be empty.
const MaxValueSize = 1 << 24
Variables ¶
var ErrFieldsOutOfOrder = errors.New("fields are out of order")
var ErrInvalidFieldNumber = errors.New("field number is invalid")
ErrInvalidFieldNumber is returned when an invalid field number is encountered.
var ErrMalformedBigInt = errors.New("invalid big integer string")
var ErrNotEnoughData = errors.New("not enough data")
var ErrOverflow = errors.New("overflow")
Functions ¶
func AnyFromJSON ¶
func AnyFromJSON(v interface{}) (interface{}, error)
AnyFromJSON converts v to a duration if it appears to be a duration. AnyFromJSON never returns an error.
func BigintToJSON ¶
func BytesFromJSON ¶
func BytesToJSON ¶
func ChainFromJSON ¶
func ChainToJSON ¶
func Copy ¶ added in v1.1.0
Copy constructs a value, copying all of the fields of an existing value.
func DurationFromJSON ¶
func DurationToJSON ¶
func Hash ¶ added in v1.3.0
func Hash(m BinaryValue) [32]byte
func MarshalBytes ¶ added in v1.1.0
func MarshalHash ¶ added in v1.1.0
func MarshalInt ¶ added in v1.1.0
func MarshalString ¶ added in v1.1.0
func MarshalUint ¶ added in v1.1.0
func SetPtr ¶ added in v1.1.0
func SetPtr(value, target interface{}) (err error)
SetPtr sets *target = value. If value cannot be assigned to *target and value has an Unwrap() method that returns a single value, SetPtr will retry with Unwrap()'s return value, recursively.
func SplitDuration ¶
func UnmarshalBytes ¶ added in v1.1.0
func UnmarshalHash ¶ added in v1.1.0
func UnmarshalInt ¶ added in v1.1.0
func UnmarshalString ¶ added in v1.1.0
func UnmarshalUint ¶ added in v1.1.0
Types ¶
type Accessor ¶ added in v1.1.0
type Accessor[V any] interface { // IsEmpty checks if the field is empty. IsEmpty(V) bool // CopyTo copies the field from the source to the destination. CopyTo(dst, src V) // Equal checks if V's field and U's field are equal. Equal(v, u V) bool // WriteTo writes the value's field to the writer. WriteTo(w *Writer, n uint, v V) // ReadField reads the value's field from the reader. ReadFrom(r *Reader, n uint, v V) bool // ToJSON writes the value's field as JSON to the builder. ToJSON(w *bytes.Buffer, v V) error // FromJSON reads the value's field as JSON. FromJSON(b []byte, v V) error }
Accessor implements various functions for a value's field.
type BigIntField ¶ added in v1.1.0
BigIntField is an Accessor for a value's big int field.
func (BigIntField[V]) CopyTo ¶ added in v1.1.0
func (f BigIntField[V]) CopyTo(dst, src V)
func (BigIntField[V]) Equal ¶ added in v1.1.0
func (f BigIntField[V]) Equal(v, u V) bool
func (BigIntField[V]) FromJSON ¶ added in v1.1.0
func (f BigIntField[V]) FromJSON(b []byte, v V) error
func (BigIntField[V]) IsEmpty ¶ added in v1.1.0
func (f BigIntField[V]) IsEmpty(v V) bool
func (BigIntField[V]) ReadFrom ¶ added in v1.1.0
func (f BigIntField[V]) ReadFrom(r *Reader, n uint, v V) bool
func (BigIntField[V]) ToJSON ¶ added in v1.1.0
func (f BigIntField[V]) ToJSON(w *bytes.Buffer, v V) error
func (BigIntField[V]) WriteTo ¶ added in v1.1.0
func (f BigIntField[V]) WriteTo(w *Writer, n uint, v V)
type BigIntPtrField ¶ added in v1.1.0
BigIntPtrField is an Accessor for a value's big int pointer field.
func (BigIntPtrField[V]) CopyTo ¶ added in v1.1.0
func (f BigIntPtrField[V]) CopyTo(dst, src V)
func (BigIntPtrField[V]) Equal ¶ added in v1.1.0
func (f BigIntPtrField[V]) Equal(v, u V) bool
func (BigIntPtrField[V]) FromJSON ¶ added in v1.1.0
func (f BigIntPtrField[V]) FromJSON(b []byte, v V) error
func (BigIntPtrField[V]) IsEmpty ¶ added in v1.1.0
func (f BigIntPtrField[V]) IsEmpty(v V) bool
func (BigIntPtrField[V]) ReadFrom ¶ added in v1.1.0
func (f BigIntPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
func (BigIntPtrField[V]) ToJSON ¶ added in v1.1.0
func (f BigIntPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
func (BigIntPtrField[V]) WriteTo ¶ added in v1.1.0
func (f BigIntPtrField[V]) WriteTo(w *Writer, n uint, v V)
type BinaryValue ¶
type BinaryValue interface { encoding.BinaryMarshaler encoding.BinaryUnmarshaler CopyAsInterface() interface{} UnmarshalBinaryFrom(io.Reader) error }
type BoolField ¶ added in v1.1.0
BoolField is an Accessor for a value's bool field.
type BoolPtrField ¶ added in v1.1.0
BoolPtrField is an Accessor for a value's bool pointer field.
func (BoolPtrField[V]) CopyTo ¶ added in v1.1.0
func (f BoolPtrField[V]) CopyTo(dst, src V)
func (BoolPtrField[V]) Equal ¶ added in v1.1.0
func (f BoolPtrField[V]) Equal(v, u V) bool
func (BoolPtrField[V]) FromJSON ¶ added in v1.1.0
func (f BoolPtrField[V]) FromJSON(b []byte, v V) error
func (BoolPtrField[V]) IsEmpty ¶ added in v1.1.0
func (f BoolPtrField[V]) IsEmpty(v V) bool
func (BoolPtrField[V]) ReadFrom ¶ added in v1.1.0
func (f BoolPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
func (BoolPtrField[V]) ToJSON ¶ added in v1.1.0
func (f BoolPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
func (BoolPtrField[V]) WriteTo ¶ added in v1.1.0
func (f BoolPtrField[V]) WriteTo(w *Writer, n uint, v V)
type BytesField ¶ added in v1.1.0
BytesField is an Accessor for a value's []byte field.
func (BytesField[V]) CopyTo ¶ added in v1.1.0
func (f BytesField[V]) CopyTo(dst, src V)
func (BytesField[V]) Equal ¶ added in v1.1.0
func (f BytesField[V]) Equal(v, u V) bool
func (BytesField[V]) FromJSON ¶ added in v1.1.0
func (f BytesField[V]) FromJSON(b []byte, v V) error
func (BytesField[V]) IsEmpty ¶ added in v1.1.0
func (f BytesField[V]) IsEmpty(v V) bool
func (BytesField[V]) ReadFrom ¶ added in v1.1.0
func (f BytesField[V]) ReadFrom(r *Reader, n uint, v V) bool
func (BytesField[V]) ToJSON ¶ added in v1.1.0
func (f BytesField[V]) ToJSON(w *bytes.Buffer, v V) error
func (BytesField[V]) WriteTo ¶ added in v1.1.0
func (f BytesField[V]) WriteTo(w *Writer, n uint, v V)
type BytesPtrField ¶ added in v1.1.0
BytesPtrField is an Accessor for a value's []byte pointer field.
func (BytesPtrField[V]) CopyTo ¶ added in v1.1.0
func (f BytesPtrField[V]) CopyTo(dst, src V)
func (BytesPtrField[V]) Equal ¶ added in v1.1.0
func (f BytesPtrField[V]) Equal(v, u V) bool
func (BytesPtrField[V]) FromJSON ¶ added in v1.1.0
func (f BytesPtrField[V]) FromJSON(b []byte, v V) error
func (BytesPtrField[V]) IsEmpty ¶ added in v1.1.0
func (f BytesPtrField[V]) IsEmpty(v V) bool
func (BytesPtrField[V]) ReadFrom ¶ added in v1.1.0
func (f BytesPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
func (BytesPtrField[V]) ToJSON ¶ added in v1.1.0
func (f BytesPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
func (BytesPtrField[V]) WriteTo ¶ added in v1.1.0
func (f BytesPtrField[V]) WriteTo(w *Writer, n uint, v V)
type BytesReader ¶ added in v1.1.0
type BytesReader interface { io.Reader io.ByteScanner }
type DurationField ¶ added in v1.1.0
DurationField is an Accessor for a value's duration field.
func (DurationField[V]) CopyTo ¶ added in v1.1.0
func (f DurationField[V]) CopyTo(dst, src V)
func (DurationField[V]) Equal ¶ added in v1.1.0
func (f DurationField[V]) Equal(v, u V) bool
func (DurationField[V]) FromJSON ¶ added in v1.1.0
func (f DurationField[V]) FromJSON(b []byte, v V) error
func (DurationField[V]) IsEmpty ¶ added in v1.1.0
func (f DurationField[V]) IsEmpty(v V) bool
func (DurationField[V]) ReadFrom ¶ added in v1.1.0
func (f DurationField[V]) ReadFrom(r *Reader, n uint, v V) bool
func (DurationField[V]) ToJSON ¶ added in v1.1.0
func (f DurationField[V]) ToJSON(w *bytes.Buffer, v V) error
func (DurationField[V]) WriteTo ¶ added in v1.1.0
func (f DurationField[V]) WriteTo(w *Writer, n uint, v V)
type DurationFields ¶
type DurationPtrField ¶ added in v1.1.0
DurationPtrField is an Accessor for a value's Duration pointer field.
func (DurationPtrField[V]) CopyTo ¶ added in v1.1.0
func (f DurationPtrField[V]) CopyTo(dst, src V)
func (DurationPtrField[V]) Equal ¶ added in v1.1.0
func (f DurationPtrField[V]) Equal(v, u V) bool
func (DurationPtrField[V]) FromJSON ¶ added in v1.1.0
func (f DurationPtrField[V]) FromJSON(b []byte, v V) error
func (DurationPtrField[V]) IsEmpty ¶ added in v1.1.0
func (f DurationPtrField[V]) IsEmpty(v V) bool
func (DurationPtrField[V]) ReadFrom ¶ added in v1.1.0
func (f DurationPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
func (DurationPtrField[V]) ToJSON ¶ added in v1.1.0
func (f DurationPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
func (DurationPtrField[V]) WriteTo ¶ added in v1.1.0
func (f DurationPtrField[V]) WriteTo(w *Writer, n uint, v V)
type EnumField ¶ added in v1.1.0
type EnumField[V any, U enumSet[W], W enumGet] func(v V) *W
EnumField is an Accessor for a value's enum field.
type EnumPtrField ¶ added in v1.1.0
type EnumPtrField[V any, U enumSet[W], W enumGet] func(v V) **W
EnumPtrField is an Accessor for a value's enum pointer field.
func (EnumPtrField[V, U, W]) CopyTo ¶ added in v1.1.0
func (f EnumPtrField[V, U, W]) CopyTo(dst, src V)
func (EnumPtrField[V, U, W]) Equal ¶ added in v1.1.0
func (f EnumPtrField[V, U, W]) Equal(v, u V) bool
func (EnumPtrField[V, U, W]) FromJSON ¶ added in v1.1.0
func (f EnumPtrField[V, U, W]) FromJSON(b []byte, v V) error
func (EnumPtrField[V, U, W]) IsEmpty ¶ added in v1.1.0
func (f EnumPtrField[V, U, W]) IsEmpty(v V) bool
func (EnumPtrField[V, U, W]) ReadFrom ¶ added in v1.1.0
func (f EnumPtrField[V, U, W]) ReadFrom(r *Reader, n uint, v V) bool
func (EnumPtrField[V, U, W]) ToJSON ¶ added in v1.1.0
func (f EnumPtrField[V, U, W]) ToJSON(w *bytes.Buffer, v V) error
func (EnumPtrField[V, U, W]) WriteTo ¶ added in v1.1.0
func (f EnumPtrField[V, U, W]) WriteTo(w *Writer, n uint, v V)
type EnumValueGetter ¶
type EnumValueGetter interface {
GetEnumValue() uint64
}
type EnumValueSetter ¶
type Field ¶ added in v1.1.0
type Field[V any] struct { Accessor[V] Name string OmitEmpty bool Required bool Number uint Binary bool }
Field is a named accessor for a field of V.
type FloatField ¶ added in v1.1.0
FloatField is an Accessor for a value's float64 field.
func (FloatField[V]) CopyTo ¶ added in v1.1.0
func (f FloatField[V]) CopyTo(dst, src V)
func (FloatField[V]) Equal ¶ added in v1.1.0
func (f FloatField[V]) Equal(v, u V) bool
func (FloatField[V]) FromJSON ¶ added in v1.1.0
func (f FloatField[V]) FromJSON(b []byte, v V) error
func (FloatField[V]) IsEmpty ¶ added in v1.1.0
func (f FloatField[V]) IsEmpty(v V) bool
func (FloatField[V]) ReadFrom ¶ added in v1.1.0
func (f FloatField[V]) ReadFrom(r *Reader, n uint, v V) bool
func (FloatField[V]) ToJSON ¶ added in v1.1.0
func (f FloatField[V]) ToJSON(w *bytes.Buffer, v V) error
func (FloatField[V]) WriteTo ¶ added in v1.1.0
func (f FloatField[V]) WriteTo(w *Writer, n uint, v V)
type FloatPtrField ¶ added in v1.1.0
FloatPtrField is an Accessor for a value's float64 pointer field.
func (FloatPtrField[V]) CopyTo ¶ added in v1.1.0
func (f FloatPtrField[V]) CopyTo(dst, src V)
func (FloatPtrField[V]) Equal ¶ added in v1.1.0
func (f FloatPtrField[V]) Equal(v, u V) bool
func (FloatPtrField[V]) FromJSON ¶ added in v1.1.0
func (f FloatPtrField[V]) FromJSON(b []byte, v V) error
func (FloatPtrField[V]) IsEmpty ¶ added in v1.1.0
func (f FloatPtrField[V]) IsEmpty(v V) bool
func (FloatPtrField[V]) ReadFrom ¶ added in v1.1.0
func (f FloatPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
func (FloatPtrField[V]) ToJSON ¶ added in v1.1.0
func (f FloatPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
func (FloatPtrField[V]) WriteTo ¶ added in v1.1.0
func (f FloatPtrField[V]) WriteTo(w *Writer, n uint, v V)
type HashField ¶ added in v1.1.0
HashField is an Accessor for a value's [32]byte field.
type HashPtrField ¶ added in v1.1.0
HashPtrField is an Accessor for a value's [32]byte pointer field.
func (HashPtrField[V]) CopyTo ¶ added in v1.1.0
func (f HashPtrField[V]) CopyTo(dst, src V)
func (HashPtrField[V]) Equal ¶ added in v1.1.0
func (f HashPtrField[V]) Equal(v, u V) bool
func (HashPtrField[V]) FromJSON ¶ added in v1.1.0
func (f HashPtrField[V]) FromJSON(b []byte, v V) error
func (HashPtrField[V]) IsEmpty ¶ added in v1.1.0
func (f HashPtrField[V]) IsEmpty(v V) bool
func (HashPtrField[V]) ReadFrom ¶ added in v1.1.0
func (f HashPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
func (HashPtrField[V]) ToJSON ¶ added in v1.1.0
func (f HashPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
func (HashPtrField[V]) WriteTo ¶ added in v1.1.0
func (f HashPtrField[V]) WriteTo(w *Writer, n uint, v V)
type IntField ¶ added in v1.1.0
IntField is an Accessor for a value's int64 field.
type IntPtrField ¶ added in v1.1.0
IntPtrField is an Accessor for a value's int64 pointer field.
func (IntPtrField[V]) CopyTo ¶ added in v1.1.0
func (f IntPtrField[V]) CopyTo(dst, src V)
func (IntPtrField[V]) Equal ¶ added in v1.1.0
func (f IntPtrField[V]) Equal(v, u V) bool
func (IntPtrField[V]) FromJSON ¶ added in v1.1.0
func (f IntPtrField[V]) FromJSON(b []byte, v V) error
func (IntPtrField[V]) IsEmpty ¶ added in v1.1.0
func (f IntPtrField[V]) IsEmpty(v V) bool
func (IntPtrField[V]) ReadFrom ¶ added in v1.1.0
func (f IntPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
func (IntPtrField[V]) ToJSON ¶ added in v1.1.0
func (f IntPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
func (IntPtrField[V]) WriteTo ¶ added in v1.1.0
func (f IntPtrField[V]) WriteTo(w *Writer, n uint, v V)
type JsonList ¶
type JsonList[T any] []T
JsonList attempts to unmarshal JSON into a slice of T and falls back to unmarshalling it into a single value of type T. Thus, fields of type JsonList can be unmarshaled from a single value or a list.
func (*JsonList[T]) UnmarshalJSON ¶
type JsonUnmarshalListWith ¶
JsonUnmarshalListWith combines the functionality of JsonList and JsonUnmarshalWith, using the given function to unmarshal JSON into a slice of T and falls back to unmarshalling it into a single value of type T.
func (*JsonUnmarshalListWith[T]) MarshalJSON ¶
func (j *JsonUnmarshalListWith[T]) MarshalJSON() ([]byte, error)
func (*JsonUnmarshalListWith[T]) UnmarshalJSON ¶
func (j *JsonUnmarshalListWith[T]) UnmarshalJSON(data []byte) error
type JsonUnmarshalWith ¶
JsonUnmarshalWith uses the given function to unmarshal JSON into a value of type T.
func (*JsonUnmarshalWith[T]) MarshalJSON ¶
func (j *JsonUnmarshalWith[T]) MarshalJSON() ([]byte, error)
func (*JsonUnmarshalWith[T]) UnmarshalJSON ¶
func (j *JsonUnmarshalWith[T]) UnmarshalJSON(data []byte) error
type Machine ¶ added in v1.1.0
type Machine[T any] struct { // Fields is a list of accessors for all of the field's types. Fields []*Field[T] // ExtraData returns the value's extra data field. ExtraData func(v T) *[]byte // Seen returns the value's seen fields field. Seen func(v T) *[]bool }
Machine is an encoder machine that knows how to encode all the fields of a type.
func (*Machine[T]) JSONMarshal ¶ added in v1.1.0
func (*Machine[T]) JSONUnmarshal ¶ added in v1.1.0
func (*Machine[T]) MarshalBinary ¶ added in v1.1.0
MarshalBinary marshals the value's fields to binary.
func (*Machine[T]) ToJSON ¶ added in v1.1.0
ToJSON writes the value's fields as JSON to the builder.
func (*Machine[T]) UnmarshalFrom ¶ added in v1.1.0
UnmarshalFrom unmarshals a value from a reader.
type ReadOnlyAccessor ¶ added in v1.1.0
type ReadOnlyAccessor[V, U any, A valueAccessor[U]] func(V) U
func (ReadOnlyAccessor[V, U, A]) CopyTo ¶ added in v1.1.0
func (f ReadOnlyAccessor[V, U, A]) CopyTo(dst, src V)
func (ReadOnlyAccessor[V, U, A]) Equal ¶ added in v1.1.0
func (f ReadOnlyAccessor[V, U, A]) Equal(v, u V) bool
func (ReadOnlyAccessor[V, U, A]) FromJSON ¶ added in v1.1.0
func (f ReadOnlyAccessor[V, U, A]) FromJSON(b []byte, v V) error
func (ReadOnlyAccessor[V, U, A]) IsEmpty ¶ added in v1.1.0
func (f ReadOnlyAccessor[V, U, A]) IsEmpty(v V) bool
func (ReadOnlyAccessor[V, U, A]) ReadFrom ¶ added in v1.1.0
func (f ReadOnlyAccessor[V, U, A]) ReadFrom(r *Reader, n uint, v V) bool
func (ReadOnlyAccessor[V, U, A]) ToJSON ¶ added in v1.1.0
func (f ReadOnlyAccessor[V, U, A]) ToJSON(w *bytes.Buffer, v V) error
func (ReadOnlyAccessor[V, U, A]) WriteTo ¶ added in v1.1.0
func (f ReadOnlyAccessor[V, U, A]) WriteTo(w *Writer, n uint, v V)
type Reader ¶
type Reader struct { IgnoreSizeLimit bool // contains filtered or unexported fields }
func (*Reader) IsEmpty ¶ added in v1.1.0
IsEmpty returns true if the object is empty. IsEmpty will always return false if called prior to any other Read method.
func (*Reader) ReadBigInt ¶
ReadBigInt reads the value as a big-endian byte slice.
func (*Reader) ReadBool ¶
ReadBool reads the value as a varint-encoded unsigned integer. An error is recorded if the value is not 0 or 1.
func (*Reader) ReadBytes ¶
ReadBytes reads the length of the value as a varint-encoded unsigned integer followed by the value.
func (*Reader) ReadDuration ¶
ReadDuration reads the value as seconds and nanoseconds, each as a varint-encoded unsigned integer.
func (*Reader) ReadString ¶
ReadString reads the length of the value as a varint-encoded unsigned integer followed by the value.
type SliceField ¶ added in v1.1.0
type SliceField[V, U any, A sliceIndexAccessor[U]] func(v V) *[]U
SliceField is an Accessor for a value's slice field.
func (SliceField[V, U, A]) CopyTo ¶ added in v1.1.0
func (f SliceField[V, U, A]) CopyTo(dst, src V)
func (SliceField[V, U, A]) Equal ¶ added in v1.1.0
func (f SliceField[V, U, A]) Equal(v, u V) bool
func (SliceField[V, U, A]) FromJSON ¶ added in v1.1.0
func (f SliceField[V, U, A]) FromJSON(b []byte, v V) error
func (SliceField[V, U, A]) IsEmpty ¶ added in v1.1.0
func (f SliceField[V, U, A]) IsEmpty(v V) bool
func (SliceField[V, U, A]) ReadFrom ¶ added in v1.1.0
func (f SliceField[V, U, A]) ReadFrom(r *Reader, n uint, v V) bool
func (SliceField[V, U, A]) ToJSON ¶ added in v1.1.0
func (f SliceField[V, U, A]) ToJSON(w *bytes.Buffer, v V) error
func (SliceField[V, U, A]) WriteTo ¶ added in v1.1.0
func (f SliceField[V, U, A]) WriteTo(w *Writer, n uint, v V)
type SliceIndex ¶ added in v1.1.0
SliceIndex is a slice and an index.
type StringField ¶ added in v1.1.0
StringField is an Accessor for a value's string field.
func (StringField[V]) CopyTo ¶ added in v1.1.0
func (f StringField[V]) CopyTo(dst, src V)
func (StringField[V]) Equal ¶ added in v1.1.0
func (f StringField[V]) Equal(v, u V) bool
func (StringField[V]) FromJSON ¶ added in v1.1.0
func (f StringField[V]) FromJSON(b []byte, v V) error
func (StringField[V]) IsEmpty ¶ added in v1.1.0
func (f StringField[V]) IsEmpty(v V) bool
func (StringField[V]) ReadFrom ¶ added in v1.1.0
func (f StringField[V]) ReadFrom(r *Reader, n uint, v V) bool
func (StringField[V]) ToJSON ¶ added in v1.1.0
func (f StringField[V]) ToJSON(w *bytes.Buffer, v V) error
func (StringField[V]) WriteTo ¶ added in v1.1.0
func (f StringField[V]) WriteTo(w *Writer, n uint, v V)
type StringPtrField ¶ added in v1.1.0
StringPtrField is an Accessor for a value's string pointer field.
func (StringPtrField[V]) CopyTo ¶ added in v1.1.0
func (f StringPtrField[V]) CopyTo(dst, src V)
func (StringPtrField[V]) Equal ¶ added in v1.1.0
func (f StringPtrField[V]) Equal(v, u V) bool
func (StringPtrField[V]) FromJSON ¶ added in v1.1.0
func (f StringPtrField[V]) FromJSON(b []byte, v V) error
func (StringPtrField[V]) IsEmpty ¶ added in v1.1.0
func (f StringPtrField[V]) IsEmpty(v V) bool
func (StringPtrField[V]) ReadFrom ¶ added in v1.1.0
func (f StringPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
func (StringPtrField[V]) ToJSON ¶ added in v1.1.0
func (f StringPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
func (StringPtrField[V]) WriteTo ¶ added in v1.1.0
func (f StringPtrField[V]) WriteTo(w *Writer, n uint, v V)
type StructField ¶ added in v1.1.0
StructField is an Accessor for a value's struct field.
func (StructField[V, U, W]) CopyTo ¶ added in v1.1.0
func (f StructField[V, U, W]) CopyTo(dst, src V)
func (StructField[V, U, W]) Equal ¶ added in v1.1.0
func (f StructField[V, U, W]) Equal(v, u V) bool
func (StructField[V, U, W]) FromJSON ¶ added in v1.1.0
func (f StructField[V, U, W]) FromJSON(b []byte, v V) error
func (StructField[V, U, W]) IsEmpty ¶ added in v1.1.0
func (f StructField[V, U, W]) IsEmpty(v V) bool
func (StructField[V, U, W]) ReadFrom ¶ added in v1.1.0
func (f StructField[V, U, W]) ReadFrom(r *Reader, n uint, v V) bool
func (StructField[V, U, W]) ToJSON ¶ added in v1.1.0
func (f StructField[V, U, W]) ToJSON(w *bytes.Buffer, v V) error
func (StructField[V, U, W]) WriteTo ¶ added in v1.1.0
func (f StructField[V, U, W]) WriteTo(w *Writer, n uint, v V)
type StructPtrField ¶ added in v1.1.0
StructPtrField is an Accessor for a value's struct pointer field.
func (StructPtrField[V, U, W]) CopyTo ¶ added in v1.1.0
func (f StructPtrField[V, U, W]) CopyTo(dst, src V)
func (StructPtrField[V, U, W]) Equal ¶ added in v1.1.0
func (f StructPtrField[V, U, W]) Equal(v, u V) bool
func (StructPtrField[V, U, W]) FromJSON ¶ added in v1.1.0
func (f StructPtrField[V, U, W]) FromJSON(b []byte, v V) error
func (StructPtrField[V, U, W]) IsEmpty ¶ added in v1.1.0
func (f StructPtrField[V, U, W]) IsEmpty(v V) bool
func (StructPtrField[V, U, W]) ReadFrom ¶ added in v1.1.0
func (f StructPtrField[V, U, W]) ReadFrom(r *Reader, n uint, v V) bool
func (StructPtrField[V, U, W]) ToJSON ¶ added in v1.1.0
func (f StructPtrField[V, U, W]) ToJSON(w *bytes.Buffer, v V) error
func (StructPtrField[V, U, W]) WriteTo ¶ added in v1.1.0
func (f StructPtrField[V, U, W]) WriteTo(w *Writer, n uint, v V)
type TimeField ¶ added in v1.1.0
TimeField is an Accessor for a value's time.Time field.
type TimePtrField ¶ added in v1.1.0
TimePtrField is an Accessor for a value's time.Time pointer field.
func (TimePtrField[V]) CopyTo ¶ added in v1.1.0
func (f TimePtrField[V]) CopyTo(dst, src V)
func (TimePtrField[V]) Equal ¶ added in v1.1.0
func (f TimePtrField[V]) Equal(v, u V) bool
func (TimePtrField[V]) FromJSON ¶ added in v1.1.0
func (f TimePtrField[V]) FromJSON(b []byte, v V) error
func (TimePtrField[V]) IsEmpty ¶ added in v1.1.0
func (f TimePtrField[V]) IsEmpty(v V) bool
func (TimePtrField[V]) ReadFrom ¶ added in v1.1.0
func (f TimePtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
func (TimePtrField[V]) ToJSON ¶ added in v1.1.0
func (f TimePtrField[V]) ToJSON(w *bytes.Buffer, v V) error
func (TimePtrField[V]) WriteTo ¶ added in v1.1.0
func (f TimePtrField[V]) WriteTo(w *Writer, n uint, v V)
type TxIDField ¶ added in v1.1.0
TxIDField is an Accessor for a value's TxID field.
type TxIDPtrField ¶ added in v1.1.0
TxIDPtrField is an Accessor for a value's TxID pointer field.
func (TxIDPtrField[V]) CopyTo ¶ added in v1.1.0
func (f TxIDPtrField[V]) CopyTo(dst, src V)
func (TxIDPtrField[V]) Equal ¶ added in v1.1.0
func (f TxIDPtrField[V]) Equal(v, u V) bool
func (TxIDPtrField[V]) FromJSON ¶ added in v1.1.0
func (f TxIDPtrField[V]) FromJSON(b []byte, v V) error
func (TxIDPtrField[V]) IsEmpty ¶ added in v1.1.0
func (f TxIDPtrField[V]) IsEmpty(v V) bool
func (TxIDPtrField[V]) ReadFrom ¶ added in v1.1.0
func (f TxIDPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
func (TxIDPtrField[V]) ToJSON ¶ added in v1.1.0
func (f TxIDPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
func (TxIDPtrField[V]) WriteTo ¶ added in v1.1.0
func (f TxIDPtrField[V]) WriteTo(w *Writer, n uint, v V)
type UintField ¶ added in v1.1.0
UintField is an Accessor for a value's uint64 field.
type UintPtrField ¶ added in v1.1.0
UintPtrField is an Accessor for a value's uint64 pointer field.
func (UintPtrField[V]) CopyTo ¶ added in v1.1.0
func (f UintPtrField[V]) CopyTo(dst, src V)
func (UintPtrField[V]) Equal ¶ added in v1.1.0
func (f UintPtrField[V]) Equal(v, u V) bool
func (UintPtrField[V]) FromJSON ¶ added in v1.1.0
func (f UintPtrField[V]) FromJSON(b []byte, v V) error
func (UintPtrField[V]) IsEmpty ¶ added in v1.1.0
func (f UintPtrField[V]) IsEmpty(v V) bool
func (UintPtrField[V]) ReadFrom ¶ added in v1.1.0
func (f UintPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
func (UintPtrField[V]) ToJSON ¶ added in v1.1.0
func (f UintPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
func (UintPtrField[V]) WriteTo ¶ added in v1.1.0
func (f UintPtrField[V]) WriteTo(w *Writer, n uint, v V)
type UnionRegistry ¶ added in v1.1.0
type UnionRegistry[T interface { comparable EnumValueGetter }, V interface { Type() T UnionValue }] struct { // contains filtered or unexported fields }
func (*UnionRegistry[T, V]) Equal ¶ added in v1.1.0
func (r *UnionRegistry[T, V]) Equal(u, v V) bool
func (*UnionRegistry[T, V]) New ¶ added in v1.1.0
func (r *UnionRegistry[T, V]) New(typ T) (V, bool)
func (*UnionRegistry[T, V]) Register ¶ added in v1.1.0
func (r *UnionRegistry[T, V]) Register(str string, new func() V, equal func(V, V) bool) error
func (*UnionRegistry[T, V]) TypeByName ¶ added in v1.1.0
func (r *UnionRegistry[T, V]) TypeByName(s string) (T, bool)
func (*UnionRegistry[T, V]) TypeByValue ¶ added in v1.1.0
func (r *UnionRegistry[T, V]) TypeByValue(v uint64) (T, bool)
func (*UnionRegistry[T, V]) TypeName ¶ added in v1.1.0
func (r *UnionRegistry[T, V]) TypeName(typ T) (string, bool)
type UnionValue ¶ added in v1.1.0
type UnionValue interface { BinaryValue UnmarshalFieldsFrom(reader *Reader) error }
type UrlField ¶ added in v1.1.0
UrlField is an Accessor for a value's Url field.
type UrlPtrField ¶ added in v1.1.0
UrlPtrField is an Accessor for a value's Url pointer field.
func (UrlPtrField[V]) CopyTo ¶ added in v1.1.0
func (f UrlPtrField[V]) CopyTo(dst, src V)
func (UrlPtrField[V]) Equal ¶ added in v1.1.0
func (f UrlPtrField[V]) Equal(v, u V) bool
func (UrlPtrField[V]) FromJSON ¶ added in v1.1.0
func (f UrlPtrField[V]) FromJSON(b []byte, v V) error
func (UrlPtrField[V]) IsEmpty ¶ added in v1.1.0
func (f UrlPtrField[V]) IsEmpty(v V) bool
func (UrlPtrField[V]) ReadFrom ¶ added in v1.1.0
func (f UrlPtrField[V]) ReadFrom(r *Reader, n uint, v V) bool
func (UrlPtrField[V]) ToJSON ¶ added in v1.1.0
func (f UrlPtrField[V]) ToJSON(w *bytes.Buffer, v V) error
func (UrlPtrField[V]) WriteTo ¶ added in v1.1.0
func (f UrlPtrField[V]) WriteTo(w *Writer, n uint, v V)
type Writer ¶
type Writer struct { IgnoreSizeLimit bool // contains filtered or unexported fields }
A Writer is used to binary-encode a struct and write it to a io.Writer.
If any attempt to write fails, all subsequent write methods are no-ops until Err is called.
func (*Writer) Reset ¶
Reset returns the total number of bytes written, the last field written, and an error, if one occurred, and resets the writer.
If a list of field names is provided, the error will be formatted as "field <name>: <err>".
func (*Writer) WriteBigInt ¶
WriteBigInt writes the value as a big-endian byte slice.
func (*Writer) WriteBytes ¶
WriteBytes writes the length of the value as a varint-encoded unsigned integer followed by the value.
func (*Writer) WriteDuration ¶
WriteDuration writes the value as seconds and nanoseconds, each as a varint-encoded unsigned integer.
func (*Writer) WriteEnum ¶
func (w *Writer) WriteEnum(n uint, v EnumValueGetter)
WriteEnum writes the value as a varint-encoded unsigned integer.
func (*Writer) WriteFloat ¶
WriteFloat writes the value as a IEEE 754 encoded floating point number.
func (*Writer) WriteString ¶
WriteString writes the length of the value as a varint-encoded unsigned integer followed by the value.
func (*Writer) WriteTime ¶
WriteTime writes the value as a varint-encoded UTC Unix timestamp (signed).