Documentation ¶
Overview ¶
Package types declares data types for Rego values and helper functions to operate on these types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var A = NewAny()
A represents the superset of all types.
var B = NewBoolean()
B represents an instance of the boolean type.
var N = NewNumber()
N represents an instance of the number type.
var S = NewString()
S represents an instance of the string type.
Functions ¶
Types ¶
type Any ¶
type Any []Type
Any represents a dynamic type.
func (Any) MarshalJSON ¶ added in v0.5.7
MarshalJSON returns the JSON encoding of t.
type Array ¶
type Array struct {
// contains filtered or unexported fields
}
Array represents the array type.
func (*Array) MarshalJSON ¶ added in v0.5.7
MarshalJSON returns the JSON encoding of t.
type Boolean ¶
type Boolean struct{}
Boolean represents the boolean type.
func (Boolean) MarshalJSON ¶ added in v0.5.7
MarshalJSON returns the JSON encoding of t.
type DynamicProperty ¶ added in v0.5.7
DynamicProperty represents a dynamic object property.
func NewDynamicProperty ¶ added in v0.5.7
func NewDynamicProperty(key, value Type) *DynamicProperty
NewDynamicProperty returns a new DynamicProperty object.
func (*DynamicProperty) MarshalJSON ¶ added in v0.5.7
func (p *DynamicProperty) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of p.
func (*DynamicProperty) String ¶ added in v0.5.7
func (p *DynamicProperty) String() string
type Function ¶ added in v0.5.9
type Function struct {
// contains filtered or unexported fields
}
Function represents a function type.
func NewFunction ¶ added in v0.5.9
NewFunction returns a new Function object where xs[:len(xs)-1] are arguments and xs[len(xs)-1] is the result type.
func (*Function) MarshalJSON ¶ added in v0.5.9
MarshalJSON returns the JSON encoding of t.
type Null ¶
type Null struct{}
Null represents the null type.
func (Null) MarshalJSON ¶ added in v0.5.7
MarshalJSON returns the JSON encoding of t.
type Number ¶
type Number struct{}
Number represents the number type.
func (Number) MarshalJSON ¶ added in v0.5.7
MarshalJSON returns the JSON encoding of t.
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object represents the object type.
func NewObject ¶
func NewObject(static []*StaticProperty, dynamic *DynamicProperty) *Object
NewObject returns a new Object type.
func (*Object) DynamicValue ¶ added in v0.5.7
DynamicValue returns the type of the object's dynamic elements.
func (*Object) Keys ¶
func (t *Object) Keys() []interface{}
Keys returns the keys of the object's static elements.
func (*Object) MarshalJSON ¶ added in v0.5.7
MarshalJSON returns the JSON encoding of t.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set represents the set type.
func (*Set) MarshalJSON ¶ added in v0.5.7
MarshalJSON returns the JSON encoding of t.
type StaticProperty ¶ added in v0.5.7
type StaticProperty struct { Key interface{} Value Type }
StaticProperty represents a static object property.
func NewStaticProperty ¶ added in v0.5.7
func NewStaticProperty(key interface{}, value Type) *StaticProperty
NewStaticProperty returns a new StaticProperty object.
func (*StaticProperty) MarshalJSON ¶ added in v0.5.7
func (p *StaticProperty) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of p.
type String ¶
type String struct{}
String represents the string type.
func (String) MarshalJSON ¶ added in v0.5.7
MarshalJSON returns the JSON encoding of t.
type Type ¶
Type represents a type of a term in the language.
func Keys ¶
Keys returns the type of keys that can be enumerated for a. For arrays, the keys are always number types, for objects the keys are always string types, and for sets the keys are always the type of the set element.