Documentation ¶
Index ¶
- type AllCut
- type AllPass
- type And
- type FieldMapper
- type MapFieldMapper
- type MatchCompiler
- type Matcher
- type MatcherGroup
- type Not
- type Or
- type SliceFieldMapper
- type StringFieldMapper
- type StringMapMatcher
- type StringMapMatcherFactory
- type StringMatcher
- type StringMatcherFactory
- type StringSliceMatcher
- type StringSliceMatcherFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllCut ¶
type AllCut[T any] struct{}
AllCut is a matcher that matches nothing. This is useful for applications like authorization, where a user/group/role may be disallowed from viewing data entirely.
type AllPass ¶
type AllPass[T any] struct{}
AllPass is a filter that matches everything and is the same as no filter. It is implemented here as a guard against universal operations occurring in the absence of filters.
type And ¶
And is a set of filters that should be evaluated as a logical AND.
type FieldMapper ¶
type FieldMapper[T any, U any] func(T, ast.Identifier) (U, error)
FieldMapper is the adapter which can fetch actual T instance data of type U leveraging the ast.Identifier definition.
type MapFieldMapper ¶
type MapFieldMapper[T any] FieldMapper[T, map[string]string]
SliceFieldMapper is the adapter which can fetch actual T instance data of type map[string]string leveraging the ast.Identifier definition.
type MatchCompiler ¶
type MatchCompiler[T any] struct { // contains filtered or unexported fields }
MatchCompiler compiles an `ast.FilterNode` into a Matcher[T] implementation.
func NewMatchCompiler ¶
func NewMatchCompiler[T any]( stringFieldMapper StringFieldMapper[T], sliceFieldMapper SliceFieldMapper[T], mapFieldMapper MapFieldMapper[T], passes ...transform.CompilerPass, ) *MatchCompiler[T]
NewMatchCompiler creates a new MatchCompiler for T instances provided the funcs which can map ast.Identifier instances to a specific T field
func (*MatchCompiler[T]) Compile ¶
func (mc *MatchCompiler[T]) Compile(filter ast.FilterNode) (Matcher[T], error)
Compile accepts an `ast.FilterNode` tree and compiles it into a `Matcher[T]` implementation which can be used to match T instances dynamically.
type Matcher ¶
type Matcher[T any] interface { String() string // Matches is the canonical in-Go function for determining if T // matches a specific implementation's rules. Matches(T) bool }
Matcher represents anything that can be used to match against given generic type T.
type MatcherGroup ¶
MatcherGroup is useful for dynamically creating group based matchers.
type Not ¶
Not negates any filter contained within it
type Or ¶
Or is a set of filters that should be evaluated as a logical OR.
type SliceFieldMapper ¶
type SliceFieldMapper[T any] FieldMapper[T, []string]
SliceFieldMapper is the adapter which can fetch actual T instance data of type []string leveraging the ast.Identifier definition.
type StringFieldMapper ¶
type StringFieldMapper[T any] FieldMapper[T, string]
StringFieldMapper is the adapter which can fetch actual T instance data of type string leveraging the ast.Identifier definition.
type StringMapMatcher ¶
type StringMapMatcher[T any] struct { Op ast.FilterOp Identifier ast.Identifier Key string // contains filtered or unexported fields }
// StringMapMatcher matches properties of a T instance which are map[string]string
func (*StringMapMatcher[T]) Matches ¶
func (smm *StringMapMatcher[T]) Matches(that T) bool
func (*StringMapMatcher[T]) String ¶
func (smm *StringMapMatcher[T]) String() string
type StringMapMatcherFactory ¶
type StringMapMatcherFactory[T any] struct { // contains filtered or unexported fields }
StringMapMatcherFactory leverages a single MapFieldMapper[T] to generate instances of StringMapMatcher[T].
func NewStringMapMatcherFactory ¶
func NewStringMapMatcherFactory[T any](fieldMapper MapFieldMapper[T]) *StringMapMatcherFactory[T]
NewStringMapMatcherFactory creates a new StringMapMatcher factory for a given T type.
func (*StringMapMatcherFactory[T]) NewStringMapMatcher ¶
func (smmf *StringMapMatcherFactory[T]) NewStringMapMatcher(op ast.FilterOp, ident ast.Identifier, key string) *StringMapMatcher[T]
NewStringMapMatcher creates a new StringMapMatcher using the provided op, field ident and key for comparison
type StringMatcher ¶
type StringMatcher[T any] struct { Op ast.FilterOp Identifier ast.Identifier Value string // contains filtered or unexported fields }
StringMatcher matches properties of a T instance which are string.
func (*StringMatcher[T]) Matches ¶
func (sm *StringMatcher[T]) Matches(that T) bool
Matches is the canonical in-Go function for determining if T matches string property comparison rules.
func (*StringMatcher[T]) String ¶
func (sm *StringMatcher[T]) String() string
type StringMatcherFactory ¶
type StringMatcherFactory[T any] struct { // contains filtered or unexported fields }
StringMatcherFactory leverages a single StringFieldMapper[T] to generate instances of StringMatcher[T].
func NewStringMatcherFactory ¶
func NewStringMatcherFactory[T any](fieldMapper StringFieldMapper[T]) *StringMatcherFactory[T]
NewStringMatcherFactory creates a new StringMatcher factory for a given T type.
func (*StringMatcherFactory[T]) NewStringMatcher ¶
func (smf *StringMatcherFactory[T]) NewStringMatcher(op ast.FilterOp, ident ast.Identifier, value string) *StringMatcher[T]
NewStringMatcher creates a new StringMatcher using the provided op, field ident, and value comparison.
type StringSliceMatcher ¶
type StringSliceMatcher[T any] struct { Op ast.FilterOp Identifier ast.Identifier Value string // contains filtered or unexported fields }
StringSliceProperty is the lowest-level type of filter. It represents a filter operation (equality, inequality, etc.) on a property that contains a string slice
func (*StringSliceMatcher[T]) Matches ¶
func (ssp *StringSliceMatcher[T]) Matches(that T) bool
func (*StringSliceMatcher[T]) String ¶
func (ssp *StringSliceMatcher[T]) String() string
type StringSliceMatcherFactory ¶
type StringSliceMatcherFactory[T any] struct { // contains filtered or unexported fields }
StringMatcherFactory leverages a single StringSliceFieldMapper[T] to generate instances of StringSliceMatcher[T].
func NewStringSliceMatcherFactory ¶
func NewStringSliceMatcherFactory[T any](fieldMapper SliceFieldMapper[T]) *StringSliceMatcherFactory[T]
NewStringSliceMatcherFactory creates a new StringMatcher factory for a given T type.
func (*StringSliceMatcherFactory[T]) NewStringSliceMatcher ¶
func (smf *StringSliceMatcherFactory[T]) NewStringSliceMatcher(op ast.FilterOp, ident ast.Identifier, value string) *StringSliceMatcher[T]
NewStringMatcher creates a new StringSliceMatcher using the provided op, field ident, and value comparison.