hint

package
v0.0.2-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2023 License: GPL-3.0 Imports: 7 Imported by: 72

Documentation

Overview

Package hint provides to handle structs and data with type and it's version.

Index

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

func EnsureParseHint(s string) Hint

EnsureParseHint tries to parse hint string, but skips to check IsValid().

func MustNewHint

func MustNewHint(s string) Hint

func NewHint

func NewHint(t Type, v util.Version) Hint

func ParseHint

func ParseHint(s string) (Hint, error)

ParseHint tries to parse hint string and also checks IsValid().

func (Hint) Bytes

func (ht Hint) Bytes() []byte

func (Hint) Equal

func (ht Hint) Equal(b Hint) bool

func (Hint) IsCompatible

func (ht Hint) IsCompatible(target Hint) bool

IsCompatible checks whether target is compatible with source. Obviously, Type should be same and version is compatible.

func (Hint) IsEmpty

func (ht Hint) IsEmpty() bool

func (Hint) IsValid

func (ht Hint) IsValid([]byte) error

func (Hint) MarshalText

func (ht Hint) MarshalText() ([]byte, error)

func (Hint) String

func (ht Hint) String() string

func (Hint) Type

func (ht Hint) Type() Type

func (*Hint) UnmarshalText

func (ht *Hint) UnmarshalText(b []byte) error

func (Hint) Version

func (ht Hint) Version() util.Version

type HintedJSONHead

type HintedJSONHead struct {
	H Hint `json:"_hint"` //nolint:tagliatelle //...
}

func NewHintedJSONHead

func NewHintedJSONHead(h Hint) HintedJSONHead

type Hinter

type Hinter interface {
	Hint() Hint
}

type SetHinter

type SetHinter interface {
	SetHint(Hint) Hinter
}

type Type

type Type string // revive:disable-line:redefines-builtin-id

func ParseFixedTypedString

func ParseFixedTypedString(s string, typesize int) (string, Type, error)

func (Type) Bytes

func (t Type) Bytes() []byte

func (Type) IsValid

func (t Type) IsValid([]byte) error

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL