Documentation
¶
Index ¶
- Constants
- Variables
- func UintMaxLastByte() byte
- func UintMaxVarintLen() int
- type DTM
- type Integer16
- type Integer32
- type Integer64
- type Integer8
- type MigrateCurrent
- type MigrateOld
- type Num32
- type Num64
- type PtrFlag
- type PtrMap
- type Registry
- type ReversePtrMap
- type TypeVersion
- type Validator
- type ValidatorFn
Constants ¶
const ( Num64RawSize = 8 Num32RawSize = 4 Num16RawSize = 2 Num8RawSize = 1 )
These constants define the number of bytes required for all uint, int, float types in Raw encoding.
const ( Uint64MaxVarintLen = 10 Uint32MaxVarintLen = 5 Uint16MaxVarintLen = 3 Uint8MaxVarintLen = 1 )
These constants define the maximum number of bytes used by Varint encoding for all uint types.
const ( Uint64MaxLastByte byte = 1 Uint32MaxLastByte byte = 15 Uint16MaxLastByte byte = 3 Uint8MaxLastByte byte = 255 )
These constants define the maximum last byte in Varint encoding for all uint types.
Variables ¶
var ErrNegativeLength = errors.New("negative length")
ErrNegativeLength happens on Unmarshal when some data was encoded with length and value, and length is negative.
var ErrOverflow = errors.New("overflow")
ErrOverflow happens on Unmarshal when bytes number limit of the type was exceeded.
var ErrUnknownDTM = errors.New("unknown DTM")
ErrUnknownDTM happens when there is no such DTM in Registry.
var ErrUnsupportedIntSize = errors.New("unsupported IntSize")
ErrUnsupportedIntSize happens on init, if system int size is not supported.
var ErrWrongFormat = errors.New("wrong format")
ErrWrongFormat happends on Unmarshal when an incorrect format is encountered.
var ErrWrongTypeVersion = errors.New("wrong TypeVersion")
ErrWrongTypeVersion happens when the type version from Registry dosn't hold a specific type.
Functions ¶
func UintMaxLastByte ¶
func UintMaxLastByte() byte
UintMaxLastByte returns the maximum last byte in Varint encoding for uint type.
func UintMaxVarintLen ¶
func UintMaxVarintLen() int
UintMaxVarintLen returns the maximum number of bytes used by Varint encoding for uint type.
Types ¶
type MigrateCurrent ¶
MigrateCurrent migrates the current data version to the old one.
type MigrateOld ¶
MigrateOld migrates the old data version to the current one.
type PtrMap ¶
type PtrMap struct {
// contains filtered or unexported fields
}
PtrMap helps to implement pointer mapping.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry contains all supported type versions.
type ReversePtrMap ¶
type ReversePtrMap struct {
// contains filtered or unexported fields
}
ReversePtrMap helps to implement pointer mapping.
func NewReversePtrMap ¶
func NewReversePtrMap() ReversePtrMap
NewReversePtrMap creates a new ReversePtrMap.
type Validator ¶
Validator is the interface that wraps Validate method.
Validate performs data validation.
type ValidatorFn ¶
ValidatorFn is a functional implementation of the Validator interface.
func (ValidatorFn[T]) Validate ¶
func (fn ValidatorFn[T]) Validate(t T) (err error)