Documentation ¶
Index ¶
- Variables
- func AsSeq[T any](val ref.Val, convert func(ref.Val) T) iter.Seq[T]
- type Convert
- type HasNext
- type Next
- type Value
- func (v *Value[T]) Contains(val ref.Val) ref.Val
- func (v *Value[T]) ConvertToNative(typ reflect.Type) (any, error)
- func (ci *Value[T]) ConvertToType(typ ref.Type) ref.Val
- func (ci *Value[T]) Equal(other ref.Val) ref.Val
- func (v *Value[T]) Get(key ref.Val) ref.Val
- func (ci *Value[T]) HasNext() ref.Val
- func (ci *Value[T]) Iterator() traits.Iterator
- func (ci *Value[T]) Next() ref.Val
- func (v *Value[T]) Size() ref.Val
- func (ci *Value[T]) Type() ref.Type
- func (ci *Value[T]) Value() any
Constants ¶
This section is empty.
Variables ¶
var Type = types.DynType.WithTraits( traits.IterableType | traits.IteratorType | traits.IndexerType | traits.SizerType | traits.ContainerType, )
Type is the type of the iterable value. Use this when defining custom CEL functions that handle (or return) iterable values.
These values are iterable, indexable, and have a size.
Functions ¶
func AsSeq ¶
AsSeq converts a CEL iterable Value instance to a sequence of elements.
Important ¶
- If the iterable is not a CEL iterable, an empty sequence is returned.
- If there are any errors during conversion, the sequence will be truncated, or the program could panic.
- Probably not a good idea to use this function in production code, but really useful for testing, debugging, and REPL-like environments where you want to quickly convert between CEL and Go types.
Types ¶
type Convert ¶
Convert is a function that converts an element of type T to a ref.Val type which can be used in CEL expressions.
type Value ¶
type Value[T any] struct { // contains filtered or unexported fields }
Value represents an iterable value in CEL expressions.
func FromSeq ¶
FromSeq creates a new iterable Value instance from a sequence of elements, which allows for simple interoperability between Go and CEL iterable types.
func (*Value[T]) ConvertToNative ¶
ConvertToNative converts the current iterable value to a native Go type.
func (*Value[T]) ConvertToType ¶
ConvertToType converts the current iterable value to a ref.Val type.
func (*Value[T]) Equal ¶
Equal checks if the current iterable value is equal to another ref.Val type.
func (*Value[T]) Get ¶
Get retrieves the value at the given key index, allowing for random access of the iterable value using an index value (like an array).
func (*Value[T]) Iterator ¶
Iterator returns the current iterable value, satisfying the traits.Iterator interface.