comp

package
v0.0.0-...-13edf00 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KWAddActor   = KnownKey("addActor")
	KWDelActor   = KnownKey("delActor")
	KWActorError = KnownKey("actorError")
	KWError      = KnownKey("error")

	KWCPCIUserData    = KnownKey("user_data")
	KWCPCISource      = KnownKey("source")
	KWCPCIDestination = KnownKey("destination")

	KWPCIExpectingReply  = KnownKey("expecting_reply")
	KWPCINetworkPriority = KnownKey("network_priority")

	KWWirtnNetwork           = KnownKey("wirtnNetwork")
	KWIartnNetworkList       = KnownKey("iartnNetworkList")
	KWIcbrtnNetwork          = KnownKey("icbrtnNetwork")
	KWIcbrtnPerformanceIndex = KnownKey("icbrtnPerformanceIndex")
	KWRmtnRejectionReason    = KnownKey("rmtnRejectionReason")
	KWRmtnDNET               = KnownKey("rmtnDNET")
	KWRbtnNetworkList        = KnownKey("rbtnNetworkList")
	KWRatnNetworkList        = KnownKey("ratnNetworkList")
	KWIrtTable               = KnownKey("irtTable")
	KWIrtaTable              = KnownKey("irtaTable")
	KWEctnDNET               = KnownKey("ectnDNET")
	KWEctnTerminationTime    = KnownKey("ectnTerminationTime")
	KWDctnDNET               = KnownKey("dctnDNET")
	KWNniNet                 = KnownKey("nniNet")
	KWNniFlag                = KnownKey("nniFlag")

	KWBvlciResultCode = KnownKey("bvlciResultCode")
	KWBvlciBDT        = KnownKey("bvlciBDT")
	KWBvlciAddress    = KnownKey("bvlciAddress")
	KWFdAddress       = KnownKey("fdAddress")
	KWFdTTL           = KnownKey("fdTTL")
	KWFdRemain        = KnownKey("fdRemain")
	KWBvlciTimeToLive = KnownKey("bvlciTimeToLive")
	KWBvlciFDT        = KnownKey("bvlciFDT")

	KWConfirmedServiceChoice   = KnownKey("choice")
	KWUnconfirmedServiceChoice = KnownKey("choice")
	KWErrorClass               = KnownKey("errorClass")
	KWErrorCode                = KnownKey("errorCode")
	KWContext                  = KnownKey("context")
	KWInvokedID                = KnownKey("invokeID")

	KWObjectName                = KnownKey("objectName")
	KWObjectIdentifier          = KnownKey("objectIdentifier")
	KWMaximumApduLengthAccepted = KnownKey("maximumApduLengthAccepted")
	KWSegmentationSupported     = KnownKey("segmentationSupported")
	KWMaxSegmentsAccepted       = KnownKey("segmentsAccepted")
	KWNumberOfAPDURetries       = KnownKey("numberOfAPDURetries")
	KWVendorIdentifier          = KnownKey("vendorIdentifier")
	KWCls                       = KnownKey("cls")
)

Variables

View Source
var NA = NewArgs

NA is a shortcut for NewArgs

NKW is a shortcut for NewKWArgs

View Source
var NoArgs = NewArgs()
View Source
var NoKWArgs = NewKWArgs

Functions

func ApplyAppliers

func ApplyAppliers[T any](options []Option, target T)

ApplyAppliers applies all appliers to target if genericOption matches GenericApplier

func ApplyGenericOption

func ApplyGenericOption[T any](options []Option, applier func(T))

ApplyGenericOption applies to applier if genericOption matches T

func ConvertSlice

func ConvertSlice[I any, O any](in []I) (out []O)

func CopyPtr

func CopyPtr[T any](t *T) *T

CopyPtr copies things that are a pointer to something

func CreateSharedSuperIfAbundant

func CreateSharedSuperIfAbundant[T any](options []Option, constructor GenericConstructor[T], cArgs Args, ckwArgs KWArgs, cOptions ...Option) (*T, error)

CreateSharedSuperIfAbundant is the actual factory/retrieval function used when the actual object is about to be build

func DeepCopy

func DeepCopy[T Copyable](copyable Copyable) T

DeepCopy copies things implementing Copyable

func ExtractAPDU

func ExtractAPDU(options []Option) (apdu readWriteModel.APDU)

ExtractAPDU gets a readWriteModel.APDU if present

func ExtractIfPresent

func ExtractIfPresent[T any](options []Option) (T, bool)

ExtractIfPresent extracts T if present

func ExtractLeafName

func ExtractLeafName(options []Option, defaultName string) string

ExtractLeafName or return default

func ExtractNLM

func ExtractNLM(options []Option) (nlm readWriteModel.NLM)

ExtractNLM gets a readWriteModel.NLM if present

func ExtractRootMessage

func ExtractRootMessage(options []Option) (rootMessage spi.Message)

ExtractRootMessage gets a spi.Message if present

func GA

func GA[T any](args Args, index int) T

GA is a shortcut for GetFromArgs

func GAO

func GAO[T any](args Args, index int, defaultValue T) (T, bool)

GAO is a shortcut for GetFromArgsOptional

func GetFromArgs

func GetFromArgs[T any](args Args, index int) T

GetFromArgs gets a value fromArgs and if not present panics

func GetFromArgsOptional

func GetFromArgsOptional[T any](args Args, index int, defaultValue T) (T, bool)

GetFromArgsOptional gets a value from Args or return default if not present

func IsNil

func IsNil(v interface{}) bool

IsNil when nil checks aren't enough

func KW

func KW[T any](kwArgs KWArgs, key KnownKey) T

KW gets a value from KWArgs and if not present panics

func KWO

func KWO[T any](kwArgs KWArgs, key KnownKey, defaultValue T) (T, bool)

KWO gets a value from KWArgs and if not present returns the supplied default value

func NK

func NK[T any, K NillableKey[T]](value *T) K

NK creates a new NillableKey of type K

func Nothing

func Nothing() (Args, KWArgs)

Nothing give NoArgs and NoKWArgs()

func OR

func OR[T comparable](a T, b T) T

OR returns a or b

func SortedMapIterator

func SortedMapIterator[K cmp.Ordered, V any](m map[K]V) iter.Seq2[K, V]

SortedMapIterator lets you iterate over an array in a deterministic way

func ToPtr

func ToPtr[T any](value T) *T

ToPtr gives a Ptr

func ToStringers

func ToStringers[I any](in []I) []fmt.Stringer

func Try

func Try(f func() error) (err error)

Try something and return panic as error

func Try1

func Try1[T any](f func() (T, error)) (v T, err error)

Try1 something and return panic as error

Types

type Arg

type Arg any

type Args

type Args []any

func NewArgs

func NewArgs(args ...any) Args

func (Args) Format

func (a Args) Format(s fmt.State, verb rune)

func (Args) String

func (a Args) String() string

type Comparable

type Comparable interface {
	Equals(other any) bool
}

type Copyable

type Copyable interface {
	DeepCopy() any
}

type Decoder

type Decoder interface {
	Decode(Arg) error
}

type Encoder

type Encoder interface {
	Encode(Arg) error
}

type Exception

type Exception struct {
	Message string
}

func (Exception) Error

func (m Exception) Error() string

type GenericApplier

type GenericApplier[T any] genericOption[func(T)]

GenericApplier wraps a func(T) as option

func OptionalOption

func OptionalOption[V any, T any](value *V, opt func(V) GenericApplier[*T]) GenericApplier[*T]

OptionalOption allows options to be applied that might be optional

func OptionalOption2

func OptionalOption2[V1 any, V2 any, T any](value1 *V1, value2 *V2, opt func(V1, V2) GenericApplier[*T]) GenericApplier[*T]

OptionalOption2 allows options to be applied that might be optional

func WrapGenericApplier

func WrapGenericApplier[T any](applier func(T)) GenericApplier[T]

WrapGenericApplier is a factory function for GenericApplier

type GenericConstructor

type GenericConstructor[T any] func(args Args, kwArgs KWArgs, options ...Option) (*T, error)

GenericConstructor is the generic signature for constructors

type GenericFunction

type GenericFunction = func(args Args, kwArgs KWArgs) error

type Initializer

type Initializer interface {
	Init(Args, KWArgs) error
}

type KWArgs

type KWArgs map[KnownKey]any

func NewKWArgs

func NewKWArgs(kw ...any) KWArgs

func (KWArgs) Format

func (k KWArgs) Format(s fmt.State, verb rune)

func (KWArgs) String

func (k KWArgs) String() string

type KnownKey

type KnownKey string

type LeafNameSupplier

type LeafNameSupplier interface {
	GetLeafName() string
}

type NillableKey

type NillableKey[T any] struct {
	Value T
	IsNil bool
}

NillableKey is a key which can be used in maps

func (NillableKey[T]) Format

func (n NillableKey[T]) Format(s fmt.State, v rune)

func (NillableKey[T]) String

func (n NillableKey[T]) String() string

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is a generic interface for transporting options which are meant to bubble up

func AddIfAbundant

func AddIfAbundant[T any](options []Option, value T) []Option

AddIfAbundant adds a generic Option for T if value is abundant

func AddLeafTypeIfAbundant

func AddLeafTypeIfAbundant[T any](options []Option, leaf *T) []Option

AddLeafTypeIfAbundant can be used to add a leaf type if not already set

func AddMultiInheritanceSupportIfAbundant

func AddMultiInheritanceSupportIfAbundant(options []Option) []Option

AddMultiInheritanceSupportIfAbundant adds a WithMultiInheritanceSupport if abundant

func AddNLMIfAbundant

func AddNLMIfAbundant(options []Option, nlm readWriteModel.NLM) []Option

AddNLMIfAbundant can be used to add a readWriteModel.NLM if not present

func AddRootMessageIfAbundant

func AddRootMessageIfAbundant(options []Option, rootMessage spi.Message) []Option

AddRootMessageIfAbundant can be used to add a spi.Message if not present

func AddSharedSuperIfAbundant

func AddSharedSuperIfAbundant[T any](options []Option) []Option

AddSharedSuperIfAbundant adds a WithSharedSuper if abundant

func AsOption

func AsOption[T any](value T) Option

AsOption converts a value T as option

func Combine

func Combine(options []Option, additionalOptions ...Option) []Option

Combine Option s with different Option s

func WithAPDU

func WithAPDU(apdu readWriteModel.APDU) Option

WithAPDU can be used to bubble up a readWriteModel.APDU

func WithLeafType

func WithLeafType[T any](leaf *T) Option

WithLeafType can be used to add a leaf type

func WithMultiInheritanceSupport

func WithMultiInheritanceSupport() Option

WithMultiInheritanceSupport is a quick way to ensure that multi inheritance is respected from a root node.

func WithNLM

func WithNLM(nlm readWriteModel.NLM) Option

WithNLM can be used to bubble up a readWriteModel.NLM

func WithRootMessage

func WithRootMessage(rootMessage spi.Message) Option

WithRootMessage can be used to bubble up a spi.Message

func WithSharedSuper

func WithSharedSuper[T any]() Option

WithSharedSuper adds a shared super holder. Useful in multi-inheritance

type PriorityItem

type PriorityItem[P cmp.Ordered, V any] struct {
	Value    V // The value of the item; arbitrary.
	Priority P // The priority of the item in the queue.
	// The Index is needed by update and is maintained by the heap.Interface methods.
	Index int // The Index of the item in the heap.
}

An PriorityItem is something we manage in a priority queue.

func (*PriorityItem[P, V]) String

func (p *PriorityItem[P, V]) String() string

type PriorityQueue

type PriorityQueue[P cmp.Ordered, V any] []*PriorityItem[P, V]

PriorityQueue implements heap.Interface and holds Items.

func (*PriorityQueue[P, V]) Clear

func (pq *PriorityQueue[P, V]) Clear()

func (PriorityQueue[P, V]) Len

func (pq PriorityQueue[P, V]) Len() int

func (PriorityQueue[P, V]) Less

func (pq PriorityQueue[P, V]) Less(i, j int) bool

func (*PriorityQueue[P, V]) Pop

func (pq *PriorityQueue[P, V]) Pop() any

func (*PriorityQueue[P, V]) Push

func (pq *PriorityQueue[P, V]) Push(x any)

func (PriorityQueue[P, V]) String

func (pq PriorityQueue[P, V]) String() string

func (PriorityQueue[P, V]) Swap

func (pq PriorityQueue[P, V]) Swap(i, j int)

type TypeError

type TypeError struct {
	Message string
}

func (TypeError) Error

func (m TypeError) Error() string

type Updater

type Updater interface {
	Update(Arg) error
}

type ValueError

type ValueError struct {
	Message string
}

func (ValueError) Error

func (m ValueError) Error() string

Jump to

Keyboard shortcuts

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