Documentation ¶
Overview ¶
Package hint provides to handle structs and data with type and it's version.
Index ¶
- Constants
- Variables
- type BaseHinter
- type CompatibleSet
- func (st *CompatibleSet) Add(ht Hint, v interface{}) error
- func (st *CompatibleSet) AddHinter(hr Hinter) error
- func (st *CompatibleSet) Find(ht Hint) interface{}
- func (st *CompatibleSet) FindBytType(t Type) (ht Hint, value interface{})
- func (st *CompatibleSet) Traverse(f func(Hint, interface{}) bool)
- type Hint
- func (ht Hint) Bytes() []byte
- func (ht Hint) Equal(b Hint) bool
- func (ht Hint) IsCompatible(target Hint) bool
- func (ht Hint) IsEmpty() bool
- func (ht Hint) IsValid([]byte) error
- func (ht Hint) MarshalText() ([]byte, error)
- func (ht Hint) String() string
- func (ht Hint) Type() Type
- func (ht *Hint) UnmarshalText(b []byte) error
- func (ht Hint) Version() util.Version
- type HintedJSONHead
- type Hinter
- type SetHinter
- type Type
Constants ¶
View Source
const HintedJSONTag = "_hint"
Variables ¶
View Source
var ( MaxVersionLength = 20 MaxHintLength = MaxTypeLength + MaxVersionLength + 1 MinHintLength = MinTypeLength + util.MinVersionLength + 1 )
View Source
var (
MinTypeLength, MaxTypeLength = 2, 100
)
Functions ¶
This section is empty.
Types ¶
type BaseHinter ¶
type BaseHinter struct {
HT Hint `json:"_hint"` //nolint:tagliatelle //...
}
func NewBaseHinter ¶
func NewBaseHinter(ht Hint) BaseHinter
func (BaseHinter) Bytes ¶
func (ht BaseHinter) Bytes() []byte
func (BaseHinter) Hint ¶
func (ht BaseHinter) Hint() Hint
func (BaseHinter) IsValid ¶
func (ht BaseHinter) IsValid(expectedType []byte) error
func (BaseHinter) SetHint ¶
func (BaseHinter) SetHint(n Hint) Hinter
type CompatibleSet ¶
type CompatibleSet struct {
// contains filtered or unexported fields
}
func NewCompatibleSet ¶
func NewCompatibleSet() *CompatibleSet
func (*CompatibleSet) Add ¶
func (st *CompatibleSet) Add(ht Hint, v interface{}) error
func (*CompatibleSet) AddHinter ¶
func (st *CompatibleSet) AddHinter(hr Hinter) error
func (*CompatibleSet) Find ¶
func (st *CompatibleSet) Find(ht Hint) interface{}
func (*CompatibleSet) FindBytType ¶
func (st *CompatibleSet) FindBytType(t Type) (ht Hint, value interface{})
func (*CompatibleSet) Traverse ¶
func (st *CompatibleSet) Traverse(f func(Hint, interface{}) bool)
type Hint ¶
type Hint struct {
// contains filtered or unexported fields
}
func EnsureParseHint ¶
EnsureParseHint tries to parse hint string, but skips to check IsValid().
func MustNewHint ¶
func (Hint) IsCompatible ¶
IsCompatible checks whether target is compatible with source. Obviously, Type should be same and version is compatible.
func (Hint) MarshalText ¶
func (*Hint) UnmarshalText ¶
type HintedJSONHead ¶
type HintedJSONHead struct {
H Hint `json:"_hint"` //nolint:tagliatelle //...
}
func NewHintedJSONHead ¶
func NewHintedJSONHead(h Hint) HintedJSONHead
type Type ¶
type Type string // revive:disable-line:redefines-builtin-id
func ParseFixedTypedString ¶
Click to show internal directories.
Click to hide internal directories.