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[T]) Add(ht Hint, v T) error
- func (st *CompatibleSet[T]) AddHinter(h Hinter) error
- func (st *CompatibleSet[T]) Find(ht Hint) (v T, found bool)
- func (st *CompatibleSet[T]) FindByString(s string) (ht Hint, v T, found bool, _ error)
- func (st *CompatibleSet[T]) FindBytType(t Type) (ht Hint, v T, found bool)
- func (st *CompatibleSet[T]) FindBytTypeString(s string) (ht Hint, v T, found bool, _ error)
- func (st *CompatibleSet[T]) Traverse(f func(Hint, T) 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 HinterJSONHead
- 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[T any] struct { // contains filtered or unexported fields }
func NewCompatibleSet ¶
func NewCompatibleSet[T any](size int) *CompatibleSet[T]
func (*CompatibleSet[T]) Add ¶
func (st *CompatibleSet[T]) Add(ht Hint, v T) error
func (*CompatibleSet[T]) AddHinter ¶
func (st *CompatibleSet[T]) AddHinter(h Hinter) error
func (*CompatibleSet[T]) Find ¶
func (st *CompatibleSet[T]) Find(ht Hint) (v T, found bool)
func (*CompatibleSet[T]) FindByString ¶
func (st *CompatibleSet[T]) FindByString(s string) (ht Hint, v T, found bool, _ error)
func (*CompatibleSet[T]) FindBytType ¶
func (st *CompatibleSet[T]) FindBytType(t Type) (ht Hint, v T, found bool)
func (*CompatibleSet[T]) FindBytTypeString ¶
func (st *CompatibleSet[T]) FindBytTypeString(s string) (ht Hint, v T, found bool, _ error)
func (*CompatibleSet[T]) Traverse ¶
func (st *CompatibleSet[T]) Traverse(f func(Hint, T) 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 string `json:"_hint"` //nolint:tagliatelle //...
}
type HinterJSONHead ¶
type HinterJSONHead struct {
H Hint `json:"_hint"` //nolint:tagliatelle //...
}
func NewHinterJSONHead ¶
func NewHinterJSONHead(h Hint) HinterJSONHead
type Type ¶
type Type string // revive:disable-line:redefines-builtin-id
func ParseFixedTypedString ¶
Click to show internal directories.
Click to hide internal directories.