hint

package
v0.0.0-...-b559f02 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: GPL-3.0 Imports: 5 Imported by: 45

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[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

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 string `json:"_hint"` //nolint:tagliatelle //...
}

type Hinter

type Hinter interface {
	Hint() Hint
}

type HinterJSONHead

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

func NewHinterJSONHead

func NewHinterJSONHead(h Hint) HinterJSONHead

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