Documentation ¶
Index ¶
- Variables
- func EnsureAllowed(m *Methods, pol PolicyKind) (err error)
- func EnsureMut(m *Methods, mapHasKey bool) (err error)
- func ExtendWith[T any](tr Transforms, dst, src map[string]T) error
- func ExtendWithFormat[T any](tr Transforms, dst, src map[string]T) error
- func GetKeys[K comparable, V any](m map[K]V) (keys []K)
- func GetKeysOf[K comparable, V any](m Of[K, V]) (keys []K)
- func GetStringerKeys[K StringKey, V any](m map[K]V) []string
- func MustGet[V any](mk OnMissingKey, m map[string]V, key string) (val V, err error)
- func MustGetOf[V any](mk OnMissingKey, m Of[string, V], key string) (val V, err error)
- func MustGetStringer[K StringKey, V any](mk OnMissingKey, m map[K]V, key K) (val V, err error)
- func MustSetCheckOverride[K comparable, V any](meth *Methods, m map[K]V, key K, val V) error
- func NewLRU[K comparable, V any](capacity int) *cache.Cache[K, V]
- func NonOverlapping[K comparable, V any](ex ExcludeKeys[K], m map[K]V) ([]int, bool)
- func Reverse[K comparable, V comparable](m map[K]V) (rev map[V]K)
- func Wrap[K comparable, V any](m map[K]V) wrapMap[K, V]
- type AnyHasher
- type Cache
- type CacheLike
- type DefaultMethods
- type Del
- type Empty
- type ErrMissingKey
- type ExcludeKeys
- type Hash
- type HashKind
- type HashMaker
- type HashMethods
- type Hashable
- type IntMap
- func (im *IntMap[V]) Del(key uint64)
- func (im IntMap[V]) Each(fn func(key uint64, val V))
- func (im IntMap[V]) EachErr(fn func(key uint64, val V) error) error
- func (im IntMap[V]) Get(key uint64) (V, bool)
- func (im IntMap[V]) GetAnyKey(h AnyHasher, key any) (V, bool, error)
- func (im IntMap[V]) Has(key uint64) bool
- func (im *IntMap[V]) HasAnyKey(h AnyHasher, key any) (bool, error)
- func (im *IntMap[V]) Set(key uint64, val V)
- func (im *IntMap[V]) SetAnyKey(h AnyHasher, key any, val V) error
- type KeyFormat
- type KeyTransformer
- type LRUWithCreator
- type ListKeys
- type Map
- type Methods
- type Mode
- type Mut
- type MutMap
- type MutWithMethods
- type NoTransformer
- type Numeric
- type Of
- type OnMissingKey
- type OnMissingType
- type OnPolicyViolation
- type Policy
- type PolicyKind
- type PolicyMap
- type PolicyModes
- type PolicyViolationFormat
- type RecursiveDeepHasher
- type Ref
- func (r Ref[K, V]) EnsureAllowed(pol PolicyKind) error
- func (r Ref[K, V]) Get(key K) (V, error)
- func (r Ref[K, V]) Insert(key K, val V) error
- func (r Ref[K, V]) MustGet(key K) V
- func (r Ref[K, V]) MustInsert(key K, val V)
- func (r Ref[K, V]) TryGet(key K) (V, bool)
- func (r Ref[K, V]) TryInsert(key K, val V) bool
- type Setter
- type StringHash
- type StringKey
- type StringSet
- type Transforms
- type WrapHasher
Constants ¶
This section is empty.
Variables ¶
View Source
var ( MethodModes = setUpMethods() Modes = struct { SetOnly *Methods Immut *Methods Mut *Methods }{ Immut: MethodModes[ModeImmut], SetOnly: MethodModes[ModeSetOnly], Mut: MethodModes[ModeMut], } NoTransform = &NoTransformer{} )
View Source
var EmptyVal = Empty{}
View Source
var ListWithNewline = ListFormat("'%s' is not found in map, alternatives: '%s'")
View Source
var Policies = PolicyModes{ ModeMut: NewPolicyMap(PolicyOverwrite, PolicySet), ModeImmut: NewPolicyMap(), ModeSetOnly: NewPolicyMap(PolicySet), }
View Source
var PolicyFormat = NewPolicyViolationFormat("'%s' of map/dict element is not allowed")
Functions ¶
func EnsureAllowed ¶
func EnsureAllowed(m *Methods, pol PolicyKind) (err error)
func ExtendWith ¶
func ExtendWith[T any](tr Transforms, dst, src map[string]T) error
func ExtendWithFormat ¶
func ExtendWithFormat[T any](tr Transforms, dst, src map[string]T) error
func GetKeys ¶
func GetKeys[K comparable, V any](m map[K]V) (keys []K)
func GetKeysOf ¶
func GetKeysOf[K comparable, V any](m Of[K, V]) (keys []K)
func GetStringerKeys ¶
func MustGetStringer ¶
func MustGetStringer[K StringKey, V any](mk OnMissingKey, m map[K]V, key K) (val V, err error)
func MustSetCheckOverride ¶
func MustSetCheckOverride[K comparable, V any](meth *Methods, m map[K]V, key K, val V) error
func NonOverlapping ¶
func NonOverlapping[K comparable, V any](ex ExcludeKeys[K], m map[K]V) ([]int, bool)
func Reverse ¶
func Reverse[K comparable, V comparable](m map[K]V) (rev map[V]K)
func Wrap ¶
func Wrap[K comparable, V any](m map[K]V) wrapMap[K, V]
Types ¶
type DefaultMethods ¶
type ErrMissingKey ¶
type ErrMissingKey struct {
Key any
}
func (*ErrMissingKey) Error ¶
func (err *ErrMissingKey) Error() string
type ExcludeKeys ¶
type ExcludeKeys[K comparable] struct { // contains filtered or unexported fields }
func ExcludeKeysFromGroups ¶
func ExcludeKeysFromGroups[K comparable](groups ...[]K) ExcludeKeys[K]
func (ExcludeKeys[K]) GetAsSlice ¶
func (ex ExcludeKeys[K]) GetAsSlice(idx int) []K
func (ExcludeKeys[K]) GroupHas ¶
func (ex ExcludeKeys[K]) GroupHas(key K) (int, bool)
type IntMap ¶
type IntMap[V any] struct { // contains filtered or unexported fields }
IntMap maps uint64 keys to generic values. It implements the OfMut interface. It can be used as a map in situations where multiple types has to be used as keys, by hashing the value of the type used as a key to get an uint64 value to be used as a key.
type KeyTransformer ¶
type LRUWithCreator ¶
type LRUWithCreator[K, V any] struct { // contains filtered or unexported fields }
type ListKeys ¶
type ListKeys struct {
// contains filtered or unexported fields
}
func ListFormat ¶
func (ListKeys) HandleMissingAnyKey ¶
func (ListKeys) HandleMissingKey ¶
func (ListKeys) WithFormat ¶
func (ListKeys) WithSeparator ¶
type Map ¶
type Map[K comparable, V any] struct { // contains filtered or unexported fields }
func NewMap ¶
func NewMap[K comparable, V any]() Map[K, V]
type Methods ¶
type Methods struct { OnMissingKey OnMissingType Policy OnPolicyViolation }
func (*Methods) EnsureAllowed ¶
func (m *Methods) EnsureAllowed(pol PolicyKind) error
type Mode ¶
type Mode int
ENUM(
Mut Immut SetOnly Total
)
const ( // Mut PolicyMode = iota // Immut // SetOnly // PolicyModeTotal ModeMut Mode = iota ModeImmut ModeSetOnly ModeTotal NoOverwrite = ModeSetOnly )
type MutMap ¶
type MutMap[K comparable, V any] struct { Map[K, V] }
func NewMapMut ¶
func NewMapMut[K comparable, V any]() MutMap[K, V]
func NewMapMutCap ¶
func NewMapMutCap[K comparable, V any](capacity int) MutMap[K, V]
type MutWithMethods ¶
type MutWithMethods[K, V any] struct { // contains filtered or unexported fields }
func (MutWithMethods[K, V]) Get ¶
func (m MutWithMethods[K, V]) Get(key K) (V, bool)
func (MutWithMethods[K, V]) Has ¶
func (m MutWithMethods[K, V]) Has(key K) bool
func (MutWithMethods[K, V]) Set ¶
func (m MutWithMethods[K, V]) Set(key K, val V) error
func (MutWithMethods[K, V]) Update ¶
func (m MutWithMethods[K, V]) Update(dict Of[K, V]) error
type NoTransformer ¶
type NoTransformer struct{}
func (NoTransformer) TransformKey ¶
func (NoTransformer) TransformKey(key string) (string, error)
type Numeric ¶
type Numeric interface { constraints.Integer | constraints.Float }
type OnMissingKey ¶
type OnMissingType ¶
type OnPolicyViolation ¶
type OnPolicyViolation interface {
HandlePolicyViolation(pol PolicyKind) (err error)
}
type Policy ¶
type Policy interface { PolicyAllowed(pol PolicyKind) (allowed bool) AllowPolicy(pol PolicyKind) }
type PolicyKind ¶
type PolicyKind int
const ( PolicySet PolicyKind = iota PolicyOverwrite PolicyTotal )
func (PolicyKind) String ¶
func (p PolicyKind) String() (s string)
type PolicyMap ¶
type PolicyMap map[PolicyKind]Empty
func NewPolicyMap ¶
func NewPolicyMap(policies ...PolicyKind) (pm PolicyMap)
func (PolicyMap) AllowPolicy ¶
func (pm PolicyMap) AllowPolicy(pol PolicyKind)
func (PolicyMap) PolicyAllowed ¶
func (pm PolicyMap) PolicyAllowed(pol PolicyKind) (ok bool)
type PolicyModes ¶
type PolicyViolationFormat ¶
type PolicyViolationFormat struct {
// contains filtered or unexported fields
}
func NewPolicyViolationFormat ¶
func NewPolicyViolationFormat(format string) (p PolicyViolationFormat)
func (PolicyViolationFormat) HandlePolicyViolation ¶
func (pv PolicyViolationFormat) HandlePolicyViolation(pol PolicyKind) (err error)
type RecursiveDeepHasher ¶
type RecursiveDeepHasher struct {
// contains filtered or unexported fields
}
type Ref ¶
type Ref[K comparable, V any] struct { // contains filtered or unexported fields }
func ImmutRef ¶
func ImmutRef[K comparable, V any](mapping map[K]V) Ref[K, V]
func (Ref[K, V]) EnsureAllowed ¶
func (r Ref[K, V]) EnsureAllowed(pol PolicyKind) error
func (Ref[K, V]) MustInsert ¶
func (r Ref[K, V]) MustInsert(key K, val V)
type StringHash ¶
type StringHash struct {
AnyHasher
}
type StringKey ¶
type StringKey interface { comparable fmt.Stringer }
type StringSet ¶
type StringSet struct {
// contains filtered or unexported fields
}
func NewStringSet ¶
type Transforms ¶
type Transforms struct { KeyTransform KeyTransformer Methods *Methods }
type WrapHasher ¶
type WrapHasher struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.