hint

package
v0.0.0-...-5a6e01e Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var (
	MaxVersionLength = 20
	MaxHintLength    = MaxTypeLength + MaxVersionLength + 1
)
View Source
var (
	_, MaxTypeLength = 2, 100
)

Functions

func IsValidFixedType

func IsValidFixedType(ty Type, typesize int) error

Types

type BaseHinter

type BaseHinter struct {
	// contains filtered or unexported fields
}

func NewBaseHinter

func NewBaseHinter(ht Hint) BaseHinter

func (BaseHinter) Hint

func (ht BaseHinter) Hint() Hint

func (BaseHinter) IsValid

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

func (BaseHinter) SetHint

func (ht BaseHinter) SetHint(n Hint) Hinter

type GlobalHintset

type GlobalHintset struct {
	*Hintset
}

func NewGlobalHintset

func NewGlobalHintset() *GlobalHintset

func (*GlobalHintset) Add

func (hs *GlobalHintset) Add(ht Hinter) error

func (*GlobalHintset) AddType

func (hs *GlobalHintset) AddType(ty Type) error

func (*GlobalHintset) HasType

func (hs *GlobalHintset) HasType(ty Type) bool

func (*GlobalHintset) Initialize

func (hs *GlobalHintset) Initialize() error

type Hint

type Hint struct {
	// contains filtered or unexported fields
}

func NewHint

func NewHint(ty Type, v string) Hint

func ParseHint

func ParseHint(s string) (Hint, error)

ParseHint parses string and returns Hint; it does not do valid check(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) error

IsCompatible checks whether target is compatible with source, ht. - Obviously, Type should be same - If same version, compatible - If major version is different, not compatible - If same major, but minor version of target is lower than source, not compatible - If same major and minor, but different patch version, compatible

func (Hint) IsValid

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

func (Hint) IsZero

func (ht Hint) IsZero() bool

func (Hint) MarshalBSONValue

func (ht Hint) MarshalBSONValue() (bsontype.Type, []byte, error)

func (Hint) MarshalText

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

func (Hint) RawString

func (ht Hint) RawString() string

func (Hint) String

func (ht Hint) String() string

func (Hint) Type

func (ht Hint) Type() Type

func (*Hint) UnmarshalBSONValue

func (ht *Hint) UnmarshalBSONValue(t bsontype.Type, b []byte) error

func (*Hint) UnmarshalText

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

func (Hint) Version

func (ht Hint) Version() string

type Hinter

type Hinter interface {
	Hint() Hint
}

type Hintmap

type Hintmap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewHintmap

func NewHintmap() *Hintmap

func (*Hintmap) Add

func (hm *Hintmap) Add(ht Hinter, i interface{}) error

func (*Hintmap) Compatible

func (hm *Hintmap) Compatible(ht Hinter) (interface{}, error)

func (*Hintmap) CompatibleByHint

func (hm *Hintmap) CompatibleByHint(ht Hint) (interface{}, error)

type Hintset

type Hintset struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewHintset

func NewHintset() *Hintset

func (*Hintset) Add

func (hs *Hintset) Add(ht Hinter) error

func (*Hintset) Compatible

func (hs *Hintset) Compatible(ht Hint) (Hinter, error)

func (*Hintset) Get

func (hs *Hintset) Get(ht Hint) Hinter

func (*Hintset) Hinters

func (hs *Hintset) Hinters(ty Type) []Hinter

func (*Hintset) Latest

func (hs *Hintset) Latest(ty Type) (Hinter, error)

func (*Hintset) TestAdd

func (hs *Hintset) TestAdd(ht Hinter) error

func (*Hintset) Types

func (hs *Hintset) Types() []Type

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