A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pkg.go.dev/github.com/google/cel-go/common/types below:

types package - github.com/google/cel-go/common/types - Go Packages

Package types contains the types, traits, and utilities common to all components of expression handling.

Boolean constants

Int constants used for comparison results.

View Source
var (
	
	AnyType = &Type{
		kind:            AnyKind,
		runtimeTypeName: "google.protobuf.Any",
		traitMask: traits.FieldTesterType |
			traits.IndexerType,
	}
	
	BoolType = &Type{
		kind:            BoolKind,
		runtimeTypeName: "bool",
		traitMask: traits.ComparerType |
			traits.NegatorType,
	}
	
	BytesType = &Type{
		kind:            BytesKind,
		runtimeTypeName: "bytes",
		traitMask: traits.AdderType |
			traits.ComparerType |
			traits.SizerType,
	}
	
	DoubleType = &Type{
		kind:            DoubleKind,
		runtimeTypeName: "double",
		traitMask: traits.AdderType |
			traits.ComparerType |
			traits.DividerType |
			traits.MultiplierType |
			traits.NegatorType |
			traits.SubtractorType,
	}
	
	DurationType = &Type{
		kind:            DurationKind,
		runtimeTypeName: "google.protobuf.Duration",
		traitMask: traits.AdderType |
			traits.ComparerType |
			traits.NegatorType |
			traits.ReceiverType |
			traits.SubtractorType,
	}
	
	DynType = &Type{
		kind:            DynKind,
		runtimeTypeName: "dyn",
	}
	
	ErrorType = &Type{
		kind:            ErrorKind,
		runtimeTypeName: "error",
	}
	
	IntType = &Type{
		kind:            IntKind,
		runtimeTypeName: "int",
		traitMask: traits.AdderType |
			traits.ComparerType |
			traits.DividerType |
			traits.ModderType |
			traits.MultiplierType |
			traits.NegatorType |
			traits.SubtractorType,
	}
	
	ListType = NewListType(DynType)
	
	MapType = NewMapType(DynType, DynType)
	
	NullType = &Type{
		kind:            NullTypeKind,
		runtimeTypeName: "null_type",
	}
	
	StringType = &Type{
		kind:            StringKind,
		runtimeTypeName: "string",
		traitMask: traits.AdderType |
			traits.ComparerType |
			traits.MatcherType |
			traits.ReceiverType |
			traits.SizerType,
	}
	
	TimestampType = &Type{
		kind:            TimestampKind,
		runtimeTypeName: "google.protobuf.Timestamp",
		traitMask: traits.AdderType |
			traits.ComparerType |
			traits.ReceiverType |
			traits.SubtractorType,
	}
	
	TypeType = &Type{
		kind:            TypeKind,
		runtimeTypeName: "type",
	}
	
	UintType = &Type{
		kind:            UintKind,
		runtimeTypeName: "uint",
		traitMask: traits.AdderType |
			traits.ComparerType |
			traits.DividerType |
			traits.ModderType |
			traits.MultiplierType |
			traits.SubtractorType,
	}
	
	UnknownType = &Type{
		kind:            UnknownKind,
		runtimeTypeName: "unknown",
	}
)
View Source
var (
	
	DefaultTypeAdapter = &defaultTypeAdapter{}
)
View Source
var (
	
	ProtoCELPrimitives = map[protoreflect.Kind]*Type{
		protoreflect.BoolKind:     BoolType,
		protoreflect.BytesKind:    BytesType,
		protoreflect.DoubleKind:   DoubleType,
		protoreflect.FloatKind:    DoubleType,
		protoreflect.Int32Kind:    IntType,
		protoreflect.Int64Kind:    IntType,
		protoreflect.Sint32Kind:   IntType,
		protoreflect.Sint64Kind:   IntType,
		protoreflect.Uint32Kind:   UintType,
		protoreflect.Uint64Kind:   UintType,
		protoreflect.Fixed32Kind:  UintType,
		protoreflect.Fixed64Kind:  UintType,
		protoreflect.Sfixed32Kind: IntType,
		protoreflect.Sfixed64Kind: IntType,
		protoreflect.StringKind:   StringType,
	}
)

DurationGetHours returns the duration in hours.

DurationGetMilliseconds returns duration in milliseconds.

DurationGetMinutes returns duration in minutes.

DurationGetSeconds returns duration in seconds.

Equal returns whether the two ref.Value are heterogeneously equivalent.

Format formats the value as a string. The result is only intended for human consumption and ignores errors. Do not depend on the output being stable. It may change at any time.

IndexOrError converts an input index value into either a lossless integer index or an error.

InsertMapKeyValue inserts a key, value pair into the target map if the target map does not already contain the given key.

If the map is mutable, it is modified in-place per the MutableMapper contract. If the map is not mutable, a copy containing the new key, value pair is made.

IsBool returns whether the input ref.Val or ref.Type is equal to BoolType.

IsError returns whether the input element ref.Type or ref.Val is equal to the ErrType singleton.

IsPrimitiveType returns whether the input element ref.Val is a primitive type. Note, primitive types do not include well-known types such as Duration and Timestamp.

IsUnknown returns whether the element ref.Val is in instance of *types.Unknown

IsUnknownOrError returns whether the input element ref.Val is an ErrType or UnknownType.

LabelErrNode returns val unaltered it is not an Err or if the error has a non-zero AST node ID already present. Otherwise the id is added to the error for recovery with the Err.NodeID method.

MaybeNoSuchOverloadErr returns the error or unknown if the input ref.Val is one of these types, else a new no such overload error.

NewDynamicList returns a traits.Lister with heterogenous elements. value should be an array of "native" types, i.e. any type that NativeToValue() can convert to a ref.Val.

NewDynamicMap returns a traits.Mapper value with dynamic key, value pairs.

NewErr creates a new Err described by the format string and args. TODO: Audit the use of this function and standardize the error messages and codes.

NewErrFromString creates a new Err with the provided message. TODO: Audit the use of this function and standardize the error messages and codes.

NewErrWithNodeID creates a new Err described by the format string and args. TODO: Audit the use of this function and standardize the error messages and codes.

NewJSONList returns a traits.Lister based on structpb.ListValue instance.

NewJSONStruct creates a traits.Mapper implementation backed by a JSON struct that has been encoded in protocol buffer form.

The `adapter` argument provides type adaptation capabilities from proto to CEL.

NewMutableList creates a new mutable list whose internal state can be modified.

NewMutableMap constructs a mutable map from an adapter and a set of map values.

NewObject returns an object based on a proto.Message value which handles conversion between protobuf type values and expression type values. Objects support indexing and iteration.

Note: the type value is pulled from the list of registered types within the type provider. If the proto type is not registered within the type provider, then this will result in an error within the type adapter / provider.

NewProtoList returns a traits.Lister based on a pb.List instance.

NewProtoMap returns a specialized traits.Mapper for handling protobuf map values.

NewRefValList returns a traits.Lister with ref.Val elements.

This type specialization is used with list literals within CEL expressions.

NewRefValMap returns a specialized traits.Mapper with CEL valued keys and values.

NewStringInterfaceMap returns a specialized traits.Mapper with string keys and interface values.

NewStringList returns a traits.Lister containing only strings.

NewStringStringMap returns a specialized traits.Mapper with string keys and values.

func NoSuchOverloadErr() ref.Val

NoSuchOverloadErr returns a new types.Err instance with a no such overload message.

StringContains returns whether the string contains a substring.

StringEndsWith returns whether the target string contains the input suffix.

StringStartsWith returns whether the target string contains the input prefix.

ToFoldableList will create a Foldable version of a list suitable for key-value pair iteration.

For values which are already Foldable, this call is a no-op. For all other values, the fold is driven via the Size() and Get() calls which means that the folding will function, but take a performance hit.

ToFoldableMap will create a Foldable version of a map suitable for key-value pair iteration.

For values which are already Foldable, this call is a no-op. For all other values, the fold is driven via the Iterator HasNext() and Next() calls as well as the map's Get() method which means that the folding will function, but take a performance hit.

TypeToExprType converts a CEL-native type representation to a protobuf CEL Type representation.

TypeToProto converts from a CEL-native type representation to canonical CEL celpb.Type protobuf type.

func UnsupportedRefValConversionErr(val any) ref.Val

UnsupportedRefValConversionErr returns a types.NewErr instance with a no such conversion message that indicates that the native value could not be converted to a CEL ref.Val.

ValOrErr either returns the existing error or creates a new one. TODO: Audit the use of this function and standardize the error messages and codes.

WrapErr wraps an existing Go error value into a CEL Err value.

Adapter converts native Go values of varying type and complexity to equivalent CEL values.

AttributeQualifier constrains the possible types which may be used to qualify an attribute.

type AttributeTrail struct {
	
}

AttributeTrail specifies a variable with an optional qualifier path. An attribute value is expected to correspond to an AbsoluteAttribute, meaning a field selection which starts with a top-level variable.

The qualifer path elements adhere to the AttributeQualifier type constraint.

NewAttributeTrail creates a new simple attribute from a variable name.

QualifyAttribute qualifies an attribute using a valid AttributeQualifier type.

Equal returns whether two attribute values have the same variable name and qualifier paths.

QualifierPath returns the optional set of qualifying fields or indices applied to the variable.

String returns the string representation of the Attribute.

Variable returns the variable name associated with the attribute.

Bool type that implements ref.Val and supports comparison and negation.

Compare implements the traits.Comparer interface method.

ConvertToNative implements the ref.Val interface method.

ConvertToType implements the ref.Val interface method.

Equal implements the ref.Val interface method.

IsZeroValue returns true if the boolean value is false.

Negate implements the traits.Negater interface method.

Type implements the ref.Val interface method.

Value implements the ref.Val interface method.

Bytes type that implements ref.Val and supports add, compare, and size operations.

Add implements traits.Adder interface method by concatenating byte sequences.

Compare implements traits.Comparer interface method by lexicographic ordering.

ConvertToNative implements the ref.Val interface method.

ConvertToType implements the ref.Val interface method.

Equal implements the ref.Val interface method.

IsZeroValue returns true if the byte array is empty.

Size implements the traits.Sizer interface method.

Type implements the ref.Val interface method.

Value implements the ref.Val interface method.

Double type that implements ref.Val, comparison, and mathematical operations.

Add implements traits.Adder.Add.

Compare implements traits.Comparer.Compare.

ConvertToNative implements ref.Val.ConvertToNative.

ConvertToType implements ref.Val.ConvertToType.

Divide implements traits.Divider.Divide.

Equal implements ref.Val.Equal.

IsZeroValue returns true if double value is 0.0

Multiply implements traits.Multiplier.Multiply.

Negate implements traits.Negater.Negate.

Subtract implements traits.Subtractor.Subtract.

Type implements ref.Val.Type.

Value implements ref.Val.Value.

Duration type that implements ref.Val and supports add, compare, negate, and subtract operators. This type is also a receiver which means it can participate in dispatch to receiver functions.

Add implements traits.Adder.Add.

Compare implements traits.Comparer.Compare.

ConvertToNative implements ref.Val.ConvertToNative.

ConvertToType implements ref.Val.ConvertToType.

Equal implements ref.Val.Equal.

IsZeroValue returns true if the duration value is zero

Negate implements traits.Negater.Negate.

Receive implements traits.Receiver.Receive.

Subtract implements traits.Subtractor.Subtract.

Type implements ref.Val.Type.

Value implements ref.Val.Value.

Err type which extends the built-in go error and implements ref.Val.

ConvertToNative implements ref.Val.ConvertToNative.

ConvertToType implements ref.Val.ConvertToType.

Equal implements ref.Val.Equal.

NodeID returns the AST node ID of the expression that returned the error.

String implements fmt.Stringer.

Type implements ref.Val.Type.

Unwrap implements errors.Unwrap.

Value implements ref.Val.Value.

Error interface which allows types types.Err values to be treated as error values.

FieldType represents a field's type value and whether that field supports presence detection.

Int type that implements ref.Val as well as comparison and math operators.

Add implements traits.Adder.Add.

Compare implements traits.Comparer.Compare.

ConvertToNative implements ref.Val.ConvertToNative.

ConvertToType implements ref.Val.ConvertToType.

Divide implements traits.Divider.Divide.

Equal implements ref.Val.Equal.

IsZeroValue returns true if integer is equal to 0

Modulo implements traits.Modder.Modulo.

Multiply implements traits.Multiplier.Multiply.

Negate implements traits.Negater.Negate.

Subtract implements traits.Subtractor.Subtract.

Type implements ref.Val.Type.

Value implements ref.Val.Value.

Kind indicates a CEL type's kind which is used to differentiate quickly between simple and complex types.

const (
	
	UnspecifiedKind Kind = iota

	
	DynKind

	
	
	
	AnyKind

	
	BoolKind

	
	BytesKind

	
	DoubleKind

	
	DurationKind

	
	ErrorKind

	
	IntKind

	
	ListKind

	
	MapKind

	
	NullTypeKind

	
	OpaqueKind

	
	StringKind

	
	StructKind

	
	TimestampKind

	
	TypeKind

	
	TypeParamKind

	
	UintKind

	
	UnknownKind
)

Null type implementation.

ConvertToNative implements ref.Val.ConvertToNative.

ConvertToType implements ref.Val.ConvertToType.

Equal implements ref.Val.Equal.

IsZeroValue returns true as null always represents an absent value.

Type implements ref.Val.Type.

Value implements ref.Val.Value.

Optional value which points to a value if non-empty.

OptionalOf returns an optional value which wraps a concrete CEL value.

ConvertToNative implements the ref.Val interface method.

ConvertToType implements the ref.Val interface method.

Equal determines whether the values contained by two optional values are equal.

GetValue returns the wrapped value contained in the optional.

HasValue returns true if the optional has a value.

Type implements the ref.Val interface method.

Value returns the underlying 'Value()' of the wrapped value, if present.

Provider specifies functions for creating new object instances and for resolving enum values by name.

Registry provides type information for a set of registered types.

NewEmptyRegistry returns a registry which is completely unconfigured.

NewRegistry accepts a list of proto message instances and returns a type provider which can create new instances of the provided message or any message that proto depends upon in its FileDescriptor.

Copy copies the current state of the registry into its own memory space.

EnumValue returns the numeric value of the given enum value name.

FindFieldType returns the field type for a checked type value. Returns false if the field could not be found.

Deprecated: use FindStructFieldType

FindIdent takes a qualified identifier name and returns a ref.Val if one exists.

FindStructFieldNames returns the set of field names for the given struct type, if the type exists in the registry.

FindStructFieldType returns the field type for a checked type value. Returns false if the field could not be found.

FindStructType returns the Type give a qualified type name.

For historical reasons, only struct types are expected to be returned through this method, and the type values are expected to be wrapped in a TypeType instance using TypeTypeWithParam(<structType>).

Returns false if not found.

FindType looks up the Type given a qualified typeName. Returns false if not found.

Deprecated: use FindStructType

NativeToValue converts various "native" types to ref.Val with this specific implementation providing support for custom proto-based types.

This method should be the inverse of ref.Val.ConvertToNative.

NewValue creates a new type value from a qualified name and map of field name to value.

Note, for each value, the Val.ConvertToNative function will be invoked to convert the Val to the field's native type. If an error occurs during conversion, the NewValue will be a types.Err.

RegisterDescriptor registers the contents of a protocol buffer `FileDescriptor`.

RegisterMessage registers a protocol buffer message and its dependencies.

RegisterType registers a type value with the provider which ensures the provider is aware of how to map the type to an identifier.

If the `ref.Type` value is a `*types.Type` it will be registered directly by its runtime type name. If the `ref.Type` value is not a `*types.Type` instance, a `*types.Type` instance which reflects the traits present on the input and the runtime type name. By default this foreign type will be treated as a types.StructKind. To avoid potential issues where the `ref.Type` values does not match the generated `*types.Type` instance, consider always using the `*types.Type` to represent type extensions to CEL, even when they're not based on protobuf types.

String type implementation which supports addition, comparison, matching, and size functions.

Add implements traits.Adder.Add.

Compare implements traits.Comparer.Compare.

ConvertToNative implements ref.Val.ConvertToNative.

ConvertToType implements ref.Val.ConvertToType.

Equal implements ref.Val.Equal.

IsZeroValue returns true if the string is empty.

Match implements traits.Matcher.Match.

Receive implements traits.Receiver.Receive.

Size implements traits.Sizer.Size.

Type implements ref.Val.Type.

Value implements ref.Val.Value.

Timestamp type implementation which supports add, compare, and subtract operations. Timestamps are also capable of participating in dynamic function dispatch to instance methods.

Add implements traits.Adder.Add.

Compare implements traits.Comparer.Compare.

ConvertToNative implements ref.Val.ConvertToNative.

ConvertToType implements ref.Val.ConvertToType.

Equal implements ref.Val.Equal.

IsZeroValue returns true if the timestamp is epoch 0.

Receive implements traits.Receiver.Receive.

Subtract implements traits.Subtractor.Subtract.

Type implements ref.Val.Type.

Value implements ref.Val.Value.

Type holds a reference to a runtime type with an optional type-checked set of type parameters.

AlphaProtoAsType converts a CEL v1alpha1.Type protobuf type to a CEL-native type representation.

ExprTypeToType converts a protobuf CEL type representation to a CEL-native type representation.

NewListType creates an instances of a list type value with the provided element type.

func NewMapType(keyType, valueType *Type) *Type

NewMapType creates an instance of a map type value with the provided key and value types.

func NewNullableType(wrapped *Type) *Type

NewNullableType creates an instance of a nullable type with the provided wrapped type.

Note: only primitive types are supported as wrapped types.

NewObjectType creates a type reference to an externally defined type, e.g. a protobuf message type.

An object type is assumed to support field presence testing and field indexing. Additionally, the type may also indicate additional traits through the use of the optional traits vararg argument.

NewObjectTypeValue creates a type reference to an externally defined type.

Deprecated: use cel.ObjectType(typeName)

NewOpaqueType creates an abstract parameterized type with a given name.

NewOptionalType creates an abstract parameterized type instance corresponding to CEL's notion of optional.

NewTypeParamType creates a parameterized type instance.

func NewTypeTypeWithParam(param *Type) *Type

NewTypeTypeWithParam creates a type with a type parameter. Used for type-checking purposes, but equivalent to TypeType otherwise.

NewTypeValue creates an opaque type which has a set of optional type traits as defined in the common/types/traits package.

Deprecated: use cel.ObjectType(typeName, traits)

ProtoAsType converts a canonical CEL celpb.Type protobuf type to a CEL-native type representation.

ConvertToNative implements ref.Val.ConvertToNative.

ConvertToType implements ref.Val.ConvertToType.

DeclaredTypeName indicates the fully qualified and parameterized type-check type name.

Equal indicates whether two types have the same runtime type name.

The name Equal is a bit of a misnomer, but for historical reasons, this is the runtime behavior. For a more accurate definition see IsType().

HasTrait implements the ref.Type interface method.

IsAssignableRuntimeType determines whether the current type is runtime assignable from the input runtimeType.

At runtime, parameterized types are erased and so a function which type-checks to support a map(string, string) will have a runtime assignable type of a map.

IsAssignableType determines whether the current type is type-check assignable from the input fromType.

IsEquivalentType indicates whether two types are equivalent. This check ignores type parameter type names.

IsExactType indicates whether the two types are exactly the same. This check also verifies type parameter type names.

Kind indicates general category of the type.

Parameters returns the list of type parameters if set.

For ListKind, Parameters()[0] represents the list element type For MapKind, Parameters()[0] represents the map key type, and Parameters()[1] represents the map value type.

String returns a human-readable definition of the type name.

Type implements the ref.Val interface method.

TypeName returns the type-erased fully qualified runtime type name.

TypeName implements the ref.Type interface method.

Value implements the ref.Val interface method.

WithTraits creates a copy of the current Type and sets the trait mask to the traits parameter.

This method should be used with Opaque types where the type acts like a container, e.g. vector.

Uint type implementation which supports comparison and math operators.

Add implements traits.Adder.Add.

Compare implements traits.Comparer.Compare.

ConvertToNative implements ref.Val.ConvertToNative.

ConvertToType implements ref.Val.ConvertToType.

Divide implements traits.Divider.Divide.

Equal implements ref.Val.Equal.

IsZeroValue returns true if the uint is zero.

Modulo implements traits.Modder.Modulo.

Multiply implements traits.Multiplier.Multiply.

Subtract implements traits.Subtractor.Subtract.

Type implements ref.Val.Type.

Value implements ref.Val.Value.

Unknown type which collects expression ids which caused the current value to become unknown.

MaybeMergeUnknowns determines whether an input value and another, possibly nil, unknown will produce an unknown result.

If the input `val` is another Unknown, then the result will be the merge of the `val` and the input `unk`. If the `val` is not unknown, then the result will depend on whether the input `unk` is nil. If both values are non-nil and unknown, then the return value will be a merge of both unknowns.

MergeUnknowns combines two unknown values into a new unknown value.

NewUnknown creates a new unknown at a given expression id for an attribute.

If the attribute is nil, the attribute value will be the `unspecifiedAttribute`.

Contains returns true if the input unknown is a subset of the current unknown.

ConvertToNative implements ref.Val.ConvertToNative.

ConvertToType is an identity function since unknown values cannot be modified.

Equal is an identity function since unknown values cannot be modified.

GetAttributeTrails returns the attribute trails, if present, missing for a given expression id.

IDs returns the set of unknown expression ids contained by this value.

Numeric identifiers are guaranteed to be in sorted order.

String implements the Stringer interface

Type implements ref.Val.Type.

Value implements ref.Val.Value.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4