Documentation
¶
Overview ¶
Package schema allows the user to define a schema for structured data along with tools for marshalling and unmarshalling.
Package schema defines the data types and schema used for defining schemas.
Index ¶
- Variables
- func EqualType(a, b Type) bool
- func EqualValue(a, b Value) bool
- func TypeOf[T any]() reflect.Type
- type ArrayType
- func (ArrayType) Class() TypeClass
- func (v *ArrayType) Copy() *ArrayType
- func (v *ArrayType) Equal(u *ArrayType) bool
- func (a *ArrayType) GoString() string
- func (a *ArrayType) GoType() reflect.Type
- func (v *ArrayType) MarshalBinary() ([]byte, error)
- func (v *ArrayType) MarshalBinaryV2(enc *binary.Encoder) error
- func (v *ArrayType) MarshalJSON() ([]byte, error)
- func (a *ArrayType) ResolveElemTo(s *ResolverSet, name string) *ArrayType
- func (t *ArrayType) SetGoType(g reflect.Type) Type
- func (t *ArrayType) String() string
- func (a *ArrayType) Underlying() *ArrayType
- func (v *ArrayType) UnmarshalBinary(b []byte) error
- func (v *ArrayType) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *ArrayType) UnmarshalJSON(b []byte) error
- func (a *ArrayType) Validate() error
- type BooleanValue
- func (v BooleanValue) Bool(name ...string) (bool, bool)
- func (v BooleanValue) Copy() BooleanValue
- func (v BooleanValue) Equal(u BooleanValue) bool
- func (BooleanValue) Kind() ValueKind
- func (v BooleanValue) MarshalBinaryV2(enc *binary.Encoder) error
- func (v BooleanValue) MarshalJSON() ([]byte, error)
- func (v BooleanValue) Number(name ...string) (float64, bool)
- func (v BooleanValue) String(name ...string) (string, bool)
- func (v *BooleanValue) UnmarshalBinaryV2(dec *binary.Decoder) error
- type CompositeType
- func (CompositeType) Class() TypeClass
- func (v *CompositeType) Copy() *CompositeType
- func (v *CompositeType) Equal(u *CompositeType) bool
- func (c *CompositeType) GoString() string
- func (c *CompositeType) GoType() reflect.Type
- func (v *CompositeType) MarshalBinary() ([]byte, error)
- func (v *CompositeType) MarshalBinaryV2(enc *binary.Encoder) error
- func (v *CompositeType) MarshalJSON() ([]byte, error)
- func (t *CompositeType) SetGoType(g reflect.Type) Type
- func (t *CompositeType) String() string
- func (v *CompositeType) UnmarshalBinary(b []byte) error
- func (v *CompositeType) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *CompositeType) UnmarshalJSON(b []byte) error
- func (c *CompositeType) Validate() error
- type EncodeContext
- type EncodingHooks
- type EnumMethods
- type EnumType
- func (EnumType) Class() TypeClass
- func (v *EnumType) Copy() *EnumType
- func (v *EnumType) Equal(u *EnumType) bool
- func (e *EnumType) GoString() string
- func (v *EnumType) MarshalBinary() ([]byte, error)
- func (v *EnumType) MarshalBinaryV2(enc *binary.Encoder) error
- func (v *EnumType) MarshalJSON() ([]byte, error)
- func (t *EnumType) SetGoType(g reflect.Type) Type
- func (t *EnumType) String() string
- func (v *EnumType) UnmarshalBinary(b []byte) error
- func (v *EnumType) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *EnumType) UnmarshalJSON(b []byte) error
- func (e *EnumType) Validate() error
- type EnumValue
- func (v *EnumValue) Copy() *EnumValue
- func (v *EnumValue) Equal(u *EnumValue) bool
- func (e *EnumValue) GoValue() any
- func (v *EnumValue) MarshalBinary() ([]byte, error)
- func (v *EnumValue) MarshalBinaryV2(enc *binary.Encoder) error
- func (v *EnumValue) MarshalJSON() ([]byte, error)
- func (e *EnumValue) String() string
- func (v *EnumValue) UnmarshalBinary(b []byte) error
- func (v *EnumValue) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *EnumValue) UnmarshalJSON(b []byte) error
- type Field
- func (v *Field) Copy() *Field
- func (v *Field) Equal(u *Field) bool
- func (v *Field) MarshalBinary() ([]byte, error)
- func (v *Field) MarshalBinaryV2(enc *binary.Encoder) error
- func (v *Field) MarshalJSON() ([]byte, error)
- func (f *Field) ResolveTo(s *ResolverSet, name string) *Field
- func (v *Field) UnmarshalBinary(b []byte) error
- func (v *Field) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *Field) UnmarshalJSON(b []byte) error
- func (f *Field) Validate() error
- type ListValue
- func (v ListValue) Bool(name ...string) (bool, bool)
- func (v ListValue) Copy() ListValue
- func (v ListValue) Equal(u ListValue) bool
- func (ListValue) Kind() ValueKind
- func (v ListValue) MarshalBinaryV2(enc *binary.Encoder) error
- func (v ListValue) MarshalJSON() ([]byte, error)
- func (v ListValue) Number(name ...string) (float64, bool)
- func (v ListValue) String(name ...string) (string, bool)
- func (v *ListValue) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *ListValue) UnmarshalJSON(b []byte) error
- type MapType
- func (MapType) Class() TypeClass
- func (v *MapType) Copy() *MapType
- func (v *MapType) Equal(u *MapType) bool
- func (m *MapType) GoString() string
- func (m *MapType) GoType() reflect.Type
- func (v *MapType) MarshalBinary() ([]byte, error)
- func (v *MapType) MarshalBinaryV2(enc *binary.Encoder) error
- func (v *MapType) MarshalJSON() ([]byte, error)
- func (m *MapType) ResolveKeyTo(s *ResolverSet, name string) *MapType
- func (m *MapType) ResolveValueTo(s *ResolverSet, name string) *MapType
- func (t *MapType) SetGoType(g reflect.Type) Type
- func (t *MapType) String() string
- func (v *MapType) UnmarshalBinary(b []byte) error
- func (v *MapType) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *MapType) UnmarshalJSON(b []byte) error
- func (m *MapType) Validate() error
- type MapValue
- func (v MapValue) Bool(name ...string) (bool, bool)
- func (v MapValue) Copy() MapValue
- func (v MapValue) Equal(u MapValue) bool
- func (MapValue) Kind() ValueKind
- func (v MapValue) MarshalBinaryV2(enc *binary.Encoder) error
- func (v MapValue) MarshalJSON() ([]byte, error)
- func (v MapValue) Number(name ...string) (float64, bool)
- func (v MapValue) String(name ...string) (string, bool)
- func (v *MapValue) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *MapValue) UnmarshalJSON(b []byte) error
- type Methods
- func (t Methods[R, W, T]) Copy(v R) R
- func (t Methods[R, W, T]) Equal(a, b R) bool
- func (t Methods[R, W, T]) MarshalBinary(v R) ([]byte, error)
- func (t Methods[R, W, T]) MarshalBinaryV2(enc *binary.Encoder, v R) error
- func (t Methods[R, W, T]) MarshalJSON(v R) ([]byte, error)
- func (t Methods[R, W, T]) SetGoType() Methods[R, W, T]
- func (t Methods[R, W, T]) UnmarshalBinary(b []byte, v W) error
- func (t Methods[R, W, T]) UnmarshalBinaryV2(dec *binary.Decoder, v W) error
- func (t Methods[R, W, T]) UnmarshalJSON(b []byte, v W) error
- type NumberValue
- func (v NumberValue) Bool(name ...string) (bool, bool)
- func (v NumberValue) Copy() NumberValue
- func (v NumberValue) Equal(u NumberValue) bool
- func (NumberValue) Kind() ValueKind
- func (v NumberValue) MarshalBinaryV2(enc *binary.Encoder) error
- func (v NumberValue) MarshalJSON() ([]byte, error)
- func (v NumberValue) Number(name ...string) (float64, bool)
- func (v NumberValue) String(name ...string) (string, bool)
- func (v *NumberValue) UnmarshalBinaryV2(dec *binary.Decoder) error
- type PointerType
- func (PointerType) Class() TypeClass
- func (v *PointerType) Copy() *PointerType
- func (v *PointerType) Equal(u *PointerType) bool
- func (p *PointerType) GoString() string
- func (p *PointerType) GoType() reflect.Type
- func (v *PointerType) MarshalBinary() ([]byte, error)
- func (v *PointerType) MarshalBinaryV2(enc *binary.Encoder) error
- func (v *PointerType) MarshalJSON() ([]byte, error)
- func (p *PointerType) ResolveElemTo(s *ResolverSet, name string) *PointerType
- func (t *PointerType) SetGoType(g reflect.Type) Type
- func (t *PointerType) String() string
- func (v *PointerType) UnmarshalBinary(b []byte) error
- func (v *PointerType) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *PointerType) UnmarshalJSON(b []byte) error
- func (p *PointerType) Validate() error
- type ResolverSet
- type Schema
- func (v *Schema) Copy() *Schema
- func (v *Schema) Equal(u *Schema) bool
- func (v *Schema) MarshalBinary() ([]byte, error)
- func (v *Schema) MarshalBinaryV2(enc *binary.Encoder) error
- func (v *Schema) MarshalJSON() ([]byte, error)
- func (v *Schema) UnmarshalBinary(b []byte) error
- func (v *Schema) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *Schema) UnmarshalJSON(b []byte) error
- func (s *Schema) Validate() error
- type SimpleType
- func (SimpleType) Class() TypeClass
- func (v *SimpleType) Copy() *SimpleType
- func (v *SimpleType) Equal(u *SimpleType) bool
- func (s *SimpleType) GoString() string
- func (s *SimpleType) GoType() reflect.Type
- func (v *SimpleType) MarshalBinary() ([]byte, error)
- func (v *SimpleType) MarshalBinaryV2(enc *binary.Encoder) error
- func (v *SimpleType) MarshalJSON() ([]byte, error)
- func (t *SimpleType) SetGoType(g reflect.Type) Type
- func (t *SimpleType) String() string
- func (v *SimpleType) UnmarshalBinary(b []byte) error
- func (v *SimpleType) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *SimpleType) UnmarshalJSON(b []byte) error
- func (s *SimpleType) Validate() error
- type SimpleTypeKind
- func (k SimpleTypeKind) GoString() string
- func (v SimpleTypeKind) MarshalBinary() ([]byte, error)
- func (v SimpleTypeKind) MarshalBinaryV2(enc *binary.Encoder) error
- func (v SimpleTypeKind) MarshalJSON() ([]byte, error)
- func (v SimpleTypeKind) String() string
- func (v *SimpleTypeKind) UnmarshalBinary(b []byte) error
- func (v *SimpleTypeKind) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *SimpleTypeKind) UnmarshalJSON(b []byte) error
- type StringValue
- func (v StringValue) Bool(name ...string) (bool, bool)
- func (v StringValue) Copy() StringValue
- func (v StringValue) Equal(u StringValue) bool
- func (StringValue) Kind() ValueKind
- func (v StringValue) MarshalBinaryV2(enc *binary.Encoder) error
- func (v StringValue) MarshalJSON() ([]byte, error)
- func (v StringValue) Number(name ...string) (float64, bool)
- func (v StringValue) String(name ...string) (string, bool)
- func (v *StringValue) UnmarshalBinaryV2(dec *binary.Decoder) error
- type Type
- type TypeBase
- func (v *TypeBase) Copy() *TypeBase
- func (t *TypeBase) EncodeSettings() MapValue
- func (v *TypeBase) Equal(u *TypeBase) bool
- func (t *TypeBase) GenerateSettings() MapValue
- func (t *TypeBase) GetName() string
- func (t *TypeBase) GetUnion() *UnionMember
- func (t *TypeBase) GoType() reflect.Type
- func (v *TypeBase) MarshalBinary() ([]byte, error)
- func (v *TypeBase) MarshalBinaryV2(enc *binary.Encoder) error
- func (v *TypeBase) MarshalJSON() ([]byte, error)
- func (v *TypeBase) UnmarshalBinary(b []byte) error
- func (v *TypeBase) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *TypeBase) UnmarshalJSON(b []byte) error
- type TypeClass
- func (v TypeClass) MarshalBinary() ([]byte, error)
- func (v TypeClass) MarshalBinaryV2(enc *binary.Encoder) error
- func (v TypeClass) MarshalJSON() ([]byte, error)
- func (v TypeClass) String() string
- func (v *TypeClass) UnmarshalBinary(b []byte) error
- func (v *TypeClass) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *TypeClass) UnmarshalJSON(b []byte) error
- type TypeReference
- func (TypeReference) Class() TypeClass
- func (v *TypeReference) Copy() *TypeReference
- func (v *TypeReference) Equal(u *TypeReference) bool
- func (r *TypeReference) GoString() string
- func (v *TypeReference) MarshalBinary() ([]byte, error)
- func (v *TypeReference) MarshalBinaryV2(enc *binary.Encoder) error
- func (v *TypeReference) MarshalJSON() ([]byte, error)
- func (t *TypeReference) SetGoType(g reflect.Type) Type
- func (t *TypeReference) String() string
- func (v *TypeReference) UnmarshalBinary(b []byte) error
- func (v *TypeReference) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *TypeReference) UnmarshalJSON(b []byte) error
- func (r *TypeReference) Validate() error
- type UnionDiscriminator
- func (v *UnionDiscriminator) Copy() *UnionDiscriminator
- func (v *UnionDiscriminator) Equal(u *UnionDiscriminator) bool
- func (v *UnionDiscriminator) MarshalBinary() ([]byte, error)
- func (v *UnionDiscriminator) MarshalBinaryV2(enc *binary.Encoder) error
- func (v *UnionDiscriminator) MarshalJSON() ([]byte, error)
- func (u *UnionDiscriminator) ResolveEnumTo(s *ResolverSet, name string) *UnionDiscriminator
- func (u *UnionDiscriminator) ResolveTypeTo(s *ResolverSet, name string) *UnionDiscriminator
- func (v *UnionDiscriminator) UnmarshalBinary(b []byte) error
- func (v *UnionDiscriminator) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *UnionDiscriminator) UnmarshalJSON(b []byte) error
- type UnionMember
- func (v *UnionMember) Copy() *UnionMember
- func (v *UnionMember) Equal(u *UnionMember) bool
- func (u *UnionMember) GoType() reflect.Type
- func (v *UnionMember) MarshalBinary() ([]byte, error)
- func (v *UnionMember) MarshalBinaryV2(enc *binary.Encoder) error
- func (v *UnionMember) MarshalJSON() ([]byte, error)
- func (u *UnionMember) ResolveTo(s *ResolverSet, name string) *UnionMember
- func (v *UnionMember) UnmarshalBinary(b []byte) error
- func (v *UnionMember) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *UnionMember) UnmarshalJSON(b []byte) error
- type UnionType
- func (UnionType) Class() TypeClass
- func (v *UnionType) Copy() *UnionType
- func (v *UnionType) Equal(u *UnionType) bool
- func (u *UnionType) GoString() string
- func (v *UnionType) MarshalBinary() ([]byte, error)
- func (v *UnionType) MarshalBinaryV2(enc *binary.Encoder) error
- func (v *UnionType) MarshalJSON() ([]byte, error)
- func (t *UnionType) SetGoType(g reflect.Type) Type
- func (t *UnionType) String() string
- func (v *UnionType) UnmarshalBinary(b []byte) error
- func (v *UnionType) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *UnionType) UnmarshalJSON(b []byte) error
- func (u *UnionType) Validate() error
- type Value
- type ValueKind
- func (v ValueKind) MarshalBinary() ([]byte, error)
- func (v ValueKind) MarshalBinaryV2(enc *binary.Encoder) error
- func (v ValueKind) MarshalJSON() ([]byte, error)
- func (v ValueKind) String() string
- func (v *ValueKind) UnmarshalBinary(b []byte) error
- func (v *ValueKind) UnmarshalBinaryV2(dec *binary.Decoder) error
- func (v *ValueKind) UnmarshalJSON(b []byte) error
Constants ¶
This section is empty.
Variables ¶
var Source string
Source is the source of the schema specification for Schema, Type, and Value.
Functions ¶
Types ¶
type ArrayType ¶
type ArrayType struct { TypeBase // Elem is the type of the array's elements. Elem Type `json:"elem"` // Length is the length of the array type, if it is fixed length. Length uint64 `json:"length"` }
ArrayType is an array type, aka list, slice, or ordered set.
func (*ArrayType) GoType ¶
GoType returns the reflect.Type of this type.
func (*ArrayType) MarshalBinary ¶
MarshalBinary marshals the ArrayType to bytes using binary.
func (*ArrayType) MarshalBinaryV2 ¶
MarshalBinary marshals the ArrayType to a binary.Encoder.
func (*ArrayType) MarshalJSON ¶
MarshalBinary marshals the ArrayType to JSON.
func (*ArrayType) ResolveElemTo ¶
func (a *ArrayType) ResolveElemTo(s *ResolverSet, name string) *ArrayType
ResolveElemTo resolves [ArrayType.Elem] to the given named type.
func (*ArrayType) Underlying ¶
Underlying returns an unnamed version of this type.
func (*ArrayType) UnmarshalBinary ¶
UnmarshalBinary unmarshals the ArrayType from bytes using binary.
func (*ArrayType) UnmarshalBinaryV2 ¶
UnmarshalBinary unmarshals the ArrayType from a binary.Decoder.
func (*ArrayType) UnmarshalJSON ¶
UnmarshalJSON unmarshals the ArrayType from JSON.
type BooleanValue ¶
type BooleanValue bool
func (BooleanValue) Bool ¶
func (v BooleanValue) Bool(name ...string) (bool, bool)
Bool resolves a value (if name is specified) and attempts to convert it to a [bool].
func (BooleanValue) Copy ¶
func (v BooleanValue) Copy() BooleanValue
Copy returns a copy of the BooleanValue.
func (BooleanValue) Equal ¶
func (v BooleanValue) Equal(u BooleanValue) bool
EqualBooleanValue returns true if V is equal to U.
func (BooleanValue) Kind ¶
func (BooleanValue) Kind() ValueKind
func (BooleanValue) MarshalBinaryV2 ¶
func (v BooleanValue) MarshalBinaryV2(enc *binary.Encoder) error
MarshalBinaryV2 marshals the value to a binary.Encoder.
func (BooleanValue) MarshalJSON ¶
func (v BooleanValue) MarshalJSON() ([]byte, error)
MarshalJSON marshals the value to JSON.
func (BooleanValue) Number ¶
func (v BooleanValue) Number(name ...string) (float64, bool)
Number resolves a value (if name is specified) and attempts to convert it to a [float64].
func (BooleanValue) String ¶
func (v BooleanValue) String(name ...string) (string, bool)
String resolves a value (if name is specified) and attempts to convert it to a [string].
func (*BooleanValue) UnmarshalBinaryV2 ¶
func (v *BooleanValue) UnmarshalBinaryV2(dec *binary.Decoder) error
UnmarshalBinaryV2 unmarshals the value from a binary.Decoder.
type CompositeType ¶
type CompositeType struct { TypeBase // Fields are the fields of the composite type. Fields []*Field `json:"fields"` // Transients are fields that are not included when encoding values of this type. Transients []*Field `json:"transients"` }
CompositeType is a composite type, aka struct or class.
func (CompositeType) Class ¶
func (CompositeType) Class() TypeClass
func (*CompositeType) Copy ¶
func (v *CompositeType) Copy() *CompositeType
Copy returns a copy of the CompositeType.
func (*CompositeType) Equal ¶
func (v *CompositeType) Equal(u *CompositeType) bool
EqualCompositeType returns true if V is equal to U.
func (*CompositeType) GoString ¶
func (c *CompositeType) GoString() string
GoString returns the Go representation of this type.
func (*CompositeType) GoType ¶
func (c *CompositeType) GoType() reflect.Type
GoType returns the reflect.Type of this type.
func (*CompositeType) MarshalBinary ¶
func (v *CompositeType) MarshalBinary() ([]byte, error)
MarshalBinary marshals the CompositeType to bytes using binary.
func (*CompositeType) MarshalBinaryV2 ¶
func (v *CompositeType) MarshalBinaryV2(enc *binary.Encoder) error
MarshalBinary marshals the CompositeType to a binary.Encoder.
func (*CompositeType) MarshalJSON ¶
func (v *CompositeType) MarshalJSON() ([]byte, error)
MarshalBinary marshals the CompositeType to JSON.
func (*CompositeType) String ¶
func (t *CompositeType) String() string
func (*CompositeType) UnmarshalBinary ¶
func (v *CompositeType) UnmarshalBinary(b []byte) error
UnmarshalBinary unmarshals the CompositeType from bytes using binary.
func (*CompositeType) UnmarshalBinaryV2 ¶
func (v *CompositeType) UnmarshalBinaryV2(dec *binary.Decoder) error
UnmarshalBinary unmarshals the CompositeType from a binary.Decoder.
func (*CompositeType) UnmarshalJSON ¶
func (v *CompositeType) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals the CompositeType from JSON.
func (*CompositeType) Validate ¶
func (c *CompositeType) Validate() error
Validate validates the composite type.
type EncodeContext ¶
EncodeContext is a traverse.Context used for encoding.
type EncodingHooks ¶
type EncodingHooks struct { MarshalReferenceTo func(*EncodeContext, Type, reflect.Value) (Type, reflect.Value, bool) MarshalJSON func(*json.Encoder, reflect.Value) (bool, error) PreUnmarshalJSON func(*json.Decoder, reflect.Value) (bool, error) UnmarshalJSON func(*json.Decoder, reflect.Value) error UnmarshalExtraJSONField func(*json.Decoder, reflect.Value, string) error MarshalBinary func(*binary.Encoder, reflect.Value) (bool, error) UnmarshalBinary func(*binary.Decoder, reflect.Value) error }
EncodingHooks are hooks to control the encoding of a Type.
type EnumMethods ¶
type EnumMethods[R constraints.Integer] struct { Methods[R, *R, *EnumType] }
EnumMethods allows generated enumeration types to use an EnumType for ByName, String, etc in a type-safe manner.
func WithEnumMethods ¶
func WithEnumMethods[R constraints.Integer](typ *EnumType) EnumMethods[R]
WithEnumMethods returns an EnumMethods for the given type.
func (EnumMethods[R]) ByName ¶
func (e EnumMethods[R]) ByName(s string) (R, bool)
ByName looks up a member of the enumeration by name.
func (EnumMethods[R]) Copy ¶
func (e EnumMethods[R]) Copy(v R) R
Copy does nothing (since enum values are immutable).
func (EnumMethods[R]) Equal ¶
func (e EnumMethods[R]) Equal(a, b R) bool
Equal returns true if A and B are the same.
func (EnumMethods[R]) SetGoType ¶
func (e EnumMethods[R]) SetGoType() EnumMethods[R]
SetGoType sets the Go type of the Type.
func (EnumMethods[R]) String ¶
func (e EnumMethods[R]) String(v R) string
String returns the label or name of the enumeration member.
type EnumType ¶
type EnumType struct { TypeBase // Underlying is the underlying type of enumeration members. Underlying *SimpleType `json:"underlying"` // Values describes the members of the enumeration. Values map[string]*EnumValue `json:"values"` }
EnumType is an enumeration type.
func (*EnumType) MarshalBinary ¶
MarshalBinary marshals the EnumType to bytes using binary.
func (*EnumType) MarshalBinaryV2 ¶
MarshalBinary marshals the EnumType to a binary.Encoder.
func (*EnumType) MarshalJSON ¶
MarshalBinary marshals the EnumType to JSON.
func (*EnumType) UnmarshalBinary ¶
UnmarshalBinary unmarshals the EnumType from bytes using binary.
func (*EnumType) UnmarshalBinaryV2 ¶
UnmarshalBinary unmarshals the EnumType from a binary.Decoder.
func (*EnumType) UnmarshalJSON ¶
UnmarshalJSON unmarshals the EnumType from JSON.
type EnumValue ¶
type EnumValue struct { // Name is the name of the enumeration member. Name string `json:"name"` // Description is the description of the enumeration member. Description string `json:"description"` // Label is the label of the enumeration member, if different from its name. Label string `json:"label"` // Value is the underlying value of the enumeration member. Value int64 `json:"value"` // Aliases are aliases of the enumeration member's name or label. Aliases []string `json:"aliases"` Enum *EnumType // contains filtered or unexported fields }
EnumValue describes a member of an enumeration.
func (*EnumValue) MarshalBinary ¶
MarshalBinary marshals the EnumValue to bytes using binary.
func (*EnumValue) MarshalBinaryV2 ¶
MarshalBinary marshals the EnumValue to a binary.Encoder.
func (*EnumValue) MarshalJSON ¶
MarshalBinary marshals the EnumValue to JSON.
func (*EnumValue) UnmarshalBinary ¶
UnmarshalBinary unmarshals the EnumValue from bytes using binary.
func (*EnumValue) UnmarshalBinaryV2 ¶
UnmarshalBinary unmarshals the EnumValue from a binary.Decoder.
func (*EnumValue) UnmarshalJSON ¶
UnmarshalJSON unmarshals the EnumValue from JSON.
type Field ¶
type Field struct { // Name is the name of the field. Name string `json:"name"` // Description is the description of the field. Description string `json:"description"` // Type is the type of the field. Type Type `json:"type"` // Optional indicates whether the field is optional. Optional bool `json:"optional"` // Encode holds settings for encoding. Encode MapValue `json:"encode"` // Generate holds settings for code generation. Generate MapValue `json:"generate"` Index uint64 ID uint Of *CompositeType }
Field is a field of a composite type.
func (*Field) MarshalBinary ¶
MarshalBinary marshals the Field to bytes using binary.
func (*Field) MarshalBinaryV2 ¶
MarshalBinary marshals the Field to a binary.Encoder.
func (*Field) MarshalJSON ¶
MarshalBinary marshals the Field to JSON.
func (*Field) ResolveTo ¶
func (f *Field) ResolveTo(s *ResolverSet, name string) *Field
ResolveTo resolves [Field.Type] to the given named type.
func (*Field) UnmarshalBinary ¶
UnmarshalBinary unmarshals the Field from bytes using binary.
func (*Field) UnmarshalBinaryV2 ¶
UnmarshalBinary unmarshals the Field from a binary.Decoder.
func (*Field) UnmarshalJSON ¶
UnmarshalJSON unmarshals the Field from JSON.
type ListValue ¶
type ListValue []Value
func (ListValue) Bool ¶
Bool resolves a value (if name is specified) and attempts to convert it to a [bool].
func (ListValue) MarshalBinaryV2 ¶
MarshalBinaryV2 marshals the value to a binary.Encoder.
func (ListValue) MarshalJSON ¶
MarshalJSON marshals the value to JSON.
func (ListValue) Number ¶
Number resolves a value (if name is specified) and attempts to convert it to a [float64].
func (ListValue) String ¶
String resolves a value (if name is specified) and attempts to convert it to a [string].
func (*ListValue) UnmarshalBinaryV2 ¶
UnmarshalBinaryV2 unmarshals the value from a binary.Decoder.
func (*ListValue) UnmarshalJSON ¶
UnmarshalJSON unmarshals the value from JSON.
type MapType ¶
type MapType struct { TypeBase // Key is the type of the map's keys. Key Type `json:"key"` // Value is the type of the map's values. Value Type `json:"value"` }
MapType is a map type, aka dictionary or associative array.
func (*MapType) GoType ¶
GoType returns the reflect.Type of this type.
func (*MapType) MarshalBinary ¶
MarshalBinary marshals the MapType to bytes using binary.
func (*MapType) MarshalBinaryV2 ¶
MarshalBinary marshals the MapType to a binary.Encoder.
func (*MapType) MarshalJSON ¶
MarshalBinary marshals the MapType to JSON.
func (*MapType) ResolveKeyTo ¶
func (m *MapType) ResolveKeyTo(s *ResolverSet, name string) *MapType
ResolveKeyTo resolves [MapType.Key] to the given named type.
func (*MapType) ResolveValueTo ¶
func (m *MapType) ResolveValueTo(s *ResolverSet, name string) *MapType
ResolveValueTo resolves [MapType.Value] to the given named type.
func (*MapType) UnmarshalBinary ¶
UnmarshalBinary unmarshals the MapType from bytes using binary.
func (*MapType) UnmarshalBinaryV2 ¶
UnmarshalBinary unmarshals the MapType from a binary.Decoder.
func (*MapType) UnmarshalJSON ¶
UnmarshalJSON unmarshals the MapType from JSON.
type MapValue ¶
func (MapValue) Bool ¶
Bool resolves a value (if name is specified) and attempts to convert it to a [bool].
func (MapValue) MarshalBinaryV2 ¶
MarshalBinaryV2 marshals the value to a binary.Encoder.
func (MapValue) MarshalJSON ¶
MarshalJSON marshals the value to JSON.
func (MapValue) Number ¶
Number resolves a value (if name is specified) and attempts to convert it to a [float64].
func (MapValue) String ¶
String resolves a value (if name is specified) and attempts to convert it to a [string].
func (*MapValue) UnmarshalBinaryV2 ¶
UnmarshalBinaryV2 unmarshals the value from a binary.Decoder.
func (*MapValue) UnmarshalJSON ¶
UnmarshalJSON unmarshals the value from JSON.
type Methods ¶
Methods allows generated types to use a Type for equality, marshalling, etc in a type-safe manner.
func WithMethods ¶
WithMethods returns a Methods for the given type.
func (Methods[R, W, T]) MarshalBinary ¶
MarshalBinary marshals the value to bytes using binary.
func (Methods[R, W, T]) MarshalBinaryV2 ¶
MarshalBinaryV2 marshals the value to a binary.Encoder
func (Methods[R, W, T]) MarshalJSON ¶
MarshalJSON marshals the value to JSON.
func (Methods[R, W, T]) UnmarshalBinary ¶
UnmarshalBinary unmarshals the value from bytes using binary.
func (Methods[R, W, T]) UnmarshalBinaryV2 ¶
UnmarshalBinaryV2 unmarshals the value from a binary.Decoder.
func (Methods[R, W, T]) UnmarshalJSON ¶
UnmarshalJSON unmarshals the value from JSON.
type NumberValue ¶
type NumberValue float64
func (NumberValue) Bool ¶
func (v NumberValue) Bool(name ...string) (bool, bool)
Bool resolves a value (if name is specified) and attempts to convert it to a [bool].
func (NumberValue) Copy ¶
func (v NumberValue) Copy() NumberValue
Copy returns a copy of the NumberValue.
func (NumberValue) Equal ¶
func (v NumberValue) Equal(u NumberValue) bool
EqualNumberValue returns true if V is equal to U.
func (NumberValue) Kind ¶
func (NumberValue) Kind() ValueKind
func (NumberValue) MarshalBinaryV2 ¶
func (v NumberValue) MarshalBinaryV2(enc *binary.Encoder) error
MarshalBinaryV2 marshals the value to a binary.Encoder.
func (NumberValue) MarshalJSON ¶
func (v NumberValue) MarshalJSON() ([]byte, error)
MarshalJSON marshals the value to JSON.
func (NumberValue) Number ¶
func (v NumberValue) Number(name ...string) (float64, bool)
Number resolves a value (if name is specified) and attempts to convert it to a [float64].
func (NumberValue) String ¶
func (v NumberValue) String(name ...string) (string, bool)
String resolves a value (if name is specified) and attempts to convert it to a [string].
func (*NumberValue) UnmarshalBinaryV2 ¶
func (v *NumberValue) UnmarshalBinaryV2(dec *binary.Decoder) error
UnmarshalBinaryV2 unmarshals the value from a binary.Decoder.
type PointerType ¶
type PointerType struct { TypeBase // Elem is the type that is pointed to. Elem Type `json:"elem"` }
PointerType is a pointer type.
func (PointerType) Class ¶
func (PointerType) Class() TypeClass
func (*PointerType) Copy ¶
func (v *PointerType) Copy() *PointerType
Copy returns a copy of the PointerType.
func (*PointerType) Equal ¶
func (v *PointerType) Equal(u *PointerType) bool
EqualPointerType returns true if V is equal to U.
func (*PointerType) GoString ¶
func (p *PointerType) GoString() string
GoString returns the Go representation of this type.
func (*PointerType) GoType ¶
func (p *PointerType) GoType() reflect.Type
GoType returns the reflect.Type of this type.
func (*PointerType) MarshalBinary ¶
func (v *PointerType) MarshalBinary() ([]byte, error)
MarshalBinary marshals the PointerType to bytes using binary.
func (*PointerType) MarshalBinaryV2 ¶
func (v *PointerType) MarshalBinaryV2(enc *binary.Encoder) error
MarshalBinary marshals the PointerType to a binary.Encoder.
func (*PointerType) MarshalJSON ¶
func (v *PointerType) MarshalJSON() ([]byte, error)
MarshalBinary marshals the PointerType to JSON.
func (*PointerType) ResolveElemTo ¶
func (p *PointerType) ResolveElemTo(s *ResolverSet, name string) *PointerType
ResolveElemTo resolves [PointerType.Elem] to the given named type.
func (*PointerType) String ¶
func (t *PointerType) String() string
func (*PointerType) UnmarshalBinary ¶
func (v *PointerType) UnmarshalBinary(b []byte) error
UnmarshalBinary unmarshals the PointerType from bytes using binary.
func (*PointerType) UnmarshalBinaryV2 ¶
func (v *PointerType) UnmarshalBinaryV2(dec *binary.Decoder) error
UnmarshalBinary unmarshals the PointerType from a binary.Decoder.
func (*PointerType) UnmarshalJSON ¶
func (v *PointerType) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals the PointerType from JSON.
func (*PointerType) Validate ¶
func (p *PointerType) Validate() error
Validate validates the pointer type.
type ResolverSet ¶
type ResolverSet []func(*Schema)
A ResolverSet is used by the schema generator to break initialization cycles.
func (ResolverSet) Resolve ¶
func (s ResolverSet) Resolve(sch *Schema, types ...Type)
Resolve executes callbacks queued by ResolveXTo calls.
type Schema ¶
Schema describes a set of related [Type]s.
func New ¶
New creates a Schema for the given set of types. New returns an error if any of the types are unnamed, or have the same name. **Validate must be called after New**.
func (*Schema) MarshalBinary ¶
MarshalBinary marshals the Schema to bytes using binary.
func (*Schema) MarshalBinaryV2 ¶
MarshalBinary marshals the Schema to a binary.Encoder.
func (*Schema) MarshalJSON ¶
MarshalBinary marshals the Schema to JSON.
func (*Schema) UnmarshalBinary ¶
UnmarshalBinary unmarshals the Schema from bytes using binary.
func (*Schema) UnmarshalBinaryV2 ¶
UnmarshalBinary unmarshals the Schema from a binary.Decoder.
func (*Schema) UnmarshalJSON ¶
UnmarshalJSON unmarshals the Schema from JSON.
type SimpleType ¶
type SimpleType struct { TypeBase // Type is a type such as [int] or [string]. Type SimpleTypeKind `json:"type"` }
SimpleType specifies a simple type, such as [int] or [string].
func (SimpleType) Class ¶
func (SimpleType) Class() TypeClass
func (*SimpleType) Copy ¶
func (v *SimpleType) Copy() *SimpleType
Copy returns a copy of the SimpleType.
func (*SimpleType) Equal ¶
func (v *SimpleType) Equal(u *SimpleType) bool
EqualSimpleType returns true if V is equal to U.
func (*SimpleType) GoString ¶
func (s *SimpleType) GoString() string
GoString returns the Go representation of this type.
func (*SimpleType) GoType ¶
func (s *SimpleType) GoType() reflect.Type
GoType returns the reflect.Type of this type.
func (*SimpleType) MarshalBinary ¶
func (v *SimpleType) MarshalBinary() ([]byte, error)
MarshalBinary marshals the SimpleType to bytes using binary.
func (*SimpleType) MarshalBinaryV2 ¶
func (v *SimpleType) MarshalBinaryV2(enc *binary.Encoder) error
MarshalBinary marshals the SimpleType to a binary.Encoder.
func (*SimpleType) MarshalJSON ¶
func (v *SimpleType) MarshalJSON() ([]byte, error)
MarshalBinary marshals the SimpleType to JSON.
func (*SimpleType) String ¶
func (t *SimpleType) String() string
func (*SimpleType) UnmarshalBinary ¶
func (v *SimpleType) UnmarshalBinary(b []byte) error
UnmarshalBinary unmarshals the SimpleType from bytes using binary.
func (*SimpleType) UnmarshalBinaryV2 ¶
func (v *SimpleType) UnmarshalBinaryV2(dec *binary.Decoder) error
UnmarshalBinary unmarshals the SimpleType from a binary.Decoder.
func (*SimpleType) UnmarshalJSON ¶
func (v *SimpleType) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals the SimpleType from JSON.
func (*SimpleType) Validate ¶
func (s *SimpleType) Validate() error
Validate validates the simple type.
type SimpleTypeKind ¶
type SimpleTypeKind int64
SimpleTypeKind is the type of SimpleType, e.g. [int] or [string].
const ( SimpleTypeBool SimpleTypeKind = 4 SimpleTypeByte SimpleTypeKind = 0 SimpleTypeBytes SimpleTypeKind = 6 SimpleTypeFloat SimpleTypeKind = 3 SimpleTypeHash SimpleTypeKind = 7 SimpleTypeInt SimpleTypeKind = 1 SimpleTypeString SimpleTypeKind = 5 SimpleTypeUint SimpleTypeKind = 2 )
func SimpleTypeKindByName ¶
func SimpleTypeKindByName(s string) (SimpleTypeKind, bool)
SimpleTypeKindByName looks up a SimpleTypeKind by name.
func (SimpleTypeKind) GoString ¶
func (k SimpleTypeKind) GoString() string
GoString returns the Go representation of this type.
func (SimpleTypeKind) MarshalBinary ¶
func (v SimpleTypeKind) MarshalBinary() ([]byte, error)
MarshalBinary marshals the SimpleTypeKind to bytes using binary.
func (SimpleTypeKind) MarshalBinaryV2 ¶
func (v SimpleTypeKind) MarshalBinaryV2(enc *binary.Encoder) error
MarshalBinary marshals the SimpleTypeKind to a binary.Encoder.
func (SimpleTypeKind) MarshalJSON ¶
func (v SimpleTypeKind) MarshalJSON() ([]byte, error)
MarshalBinary marshals the SimpleTypeKind to JSON.
func (SimpleTypeKind) String ¶
func (v SimpleTypeKind) String() string
String returns the label or name of the SimpleTypeKind.
func (*SimpleTypeKind) UnmarshalBinary ¶
func (v *SimpleTypeKind) UnmarshalBinary(b []byte) error
UnmarshalBinary unmarshals the SimpleTypeKind from bytes using binary.
func (*SimpleTypeKind) UnmarshalBinaryV2 ¶
func (v *SimpleTypeKind) UnmarshalBinaryV2(dec *binary.Decoder) error
UnmarshalBinary unmarshals the SimpleTypeKind from a binary.Decoder.
func (*SimpleTypeKind) UnmarshalJSON ¶
func (v *SimpleTypeKind) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals the SimpleTypeKind from JSON.
type StringValue ¶
type StringValue string
func (StringValue) Bool ¶
func (v StringValue) Bool(name ...string) (bool, bool)
Bool resolves a value (if name is specified) and attempts to convert it to a [bool].
func (StringValue) Copy ¶
func (v StringValue) Copy() StringValue
Copy returns a copy of the StringValue.
func (StringValue) Equal ¶
func (v StringValue) Equal(u StringValue) bool
EqualStringValue returns true if V is equal to U.
func (StringValue) Kind ¶
func (StringValue) Kind() ValueKind
func (StringValue) MarshalBinaryV2 ¶
func (v StringValue) MarshalBinaryV2(enc *binary.Encoder) error
MarshalBinaryV2 marshals the value to a binary.Encoder.
func (StringValue) MarshalJSON ¶
func (v StringValue) MarshalJSON() ([]byte, error)
MarshalJSON marshals the value to JSON.
func (StringValue) Number ¶
func (v StringValue) Number(name ...string) (float64, bool)
Number resolves a value (if name is specified) and attempts to convert it to a [float64].
func (StringValue) String ¶
func (v StringValue) String(name ...string) (string, bool)
String resolves a value (if name is specified) and attempts to convert it to a [string].
func (*StringValue) UnmarshalBinaryV2 ¶
func (v *StringValue) UnmarshalBinaryV2(dec *binary.Decoder) error
UnmarshalBinaryV2 unmarshals the value from a binary.Decoder.
type Type ¶
type Type interface { Class() TypeClass Validate() error String() string GoString() string GoType() reflect.Type SetGoType(reflect.Type) Type GetName() string GetUnion() *UnionMember EncodeSettings() MapValue GenerateSettings() MapValue // contains filtered or unexported methods }
Type describes a data type.
func UnmarshalTypeBinary ¶
UnmarshalTypeBinary unmarshals a Type from bytes using binary.
func UnmarshalTypeBinaryV2 ¶
UnmarshalTypeBinary unmarshals a Type from a binary.Decoder.
func UnmarshalTypeJSON ¶
UnmarshalTypeJSON unmarshals a Type from JSON.
type TypeBase ¶
type TypeBase struct { // Name is the name of the type, if the type is named. Name string `json:"name"` // Description is the description of the type. Description string `json:"description"` // Encode holds settings for encoding. Encode MapValue `json:"encode"` // Generate holds settings for code generation. Generate MapValue `json:"generate"` Union *UnionMember Schema *Schema Hook EncodingHooks // contains filtered or unexported fields }
TypeBase is the base implementation of Type.
func (*TypeBase) EncodeSettings ¶
func (*TypeBase) GenerateSettings ¶
func (*TypeBase) GetUnion ¶
func (t *TypeBase) GetUnion() *UnionMember
func (*TypeBase) GoType ¶
GoType returns the reflect.Type of this type.
func (*TypeBase) MarshalBinary ¶
MarshalBinary marshals the TypeBase to bytes using binary.
func (*TypeBase) MarshalBinaryV2 ¶
MarshalBinary marshals the TypeBase to a binary.Encoder.
func (*TypeBase) MarshalJSON ¶
MarshalBinary marshals the TypeBase to JSON.
func (*TypeBase) UnmarshalBinary ¶
UnmarshalBinary unmarshals the TypeBase from bytes using binary.
func (*TypeBase) UnmarshalBinaryV2 ¶
UnmarshalBinary unmarshals the TypeBase from a binary.Decoder.
func (*TypeBase) UnmarshalJSON ¶
UnmarshalJSON unmarshals the TypeBase from JSON.
type TypeClass ¶
type TypeClass int64
TypeClass is the class of a specific Type.
func TypeClassByName ¶
TypeClassByName looks up a TypeClass by name.
func (TypeClass) MarshalBinary ¶
MarshalBinary marshals the TypeClass to bytes using binary.
func (TypeClass) MarshalBinaryV2 ¶
MarshalBinary marshals the TypeClass to a binary.Encoder.
func (TypeClass) MarshalJSON ¶
MarshalBinary marshals the TypeClass to JSON.
func (*TypeClass) UnmarshalBinary ¶
UnmarshalBinary unmarshals the TypeClass from bytes using binary.
func (*TypeClass) UnmarshalBinaryV2 ¶
UnmarshalBinary unmarshals the TypeClass from a binary.Decoder.
func (*TypeClass) UnmarshalJSON ¶
UnmarshalJSON unmarshals the TypeClass from JSON.
type TypeReference ¶
type TypeReference struct {
TypeBase
}
TypeReference is a reference to a named type.
func (TypeReference) Class ¶
func (TypeReference) Class() TypeClass
func (*TypeReference) Copy ¶
func (v *TypeReference) Copy() *TypeReference
Copy returns a copy of the TypeReference.
func (*TypeReference) Equal ¶
func (v *TypeReference) Equal(u *TypeReference) bool
EqualTypeReference returns true if V is equal to U.
func (*TypeReference) GoString ¶
func (r *TypeReference) GoString() string
GoString returns the Go representation of this type.
func (*TypeReference) MarshalBinary ¶
func (v *TypeReference) MarshalBinary() ([]byte, error)
MarshalBinary marshals the TypeReference to bytes using binary.
func (*TypeReference) MarshalBinaryV2 ¶
func (v *TypeReference) MarshalBinaryV2(enc *binary.Encoder) error
MarshalBinary marshals the TypeReference to a binary.Encoder.
func (*TypeReference) MarshalJSON ¶
func (v *TypeReference) MarshalJSON() ([]byte, error)
MarshalBinary marshals the TypeReference to JSON.
func (*TypeReference) String ¶
func (t *TypeReference) String() string
func (*TypeReference) UnmarshalBinary ¶
func (v *TypeReference) UnmarshalBinary(b []byte) error
UnmarshalBinary unmarshals the TypeReference from bytes using binary.
func (*TypeReference) UnmarshalBinaryV2 ¶
func (v *TypeReference) UnmarshalBinaryV2(dec *binary.Decoder) error
UnmarshalBinary unmarshals the TypeReference from a binary.Decoder.
func (*TypeReference) UnmarshalJSON ¶
func (v *TypeReference) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals the TypeReference from JSON.
func (*TypeReference) Validate ¶
func (r *TypeReference) Validate() error
Validate validates the type reference.
type UnionDiscriminator ¶
type UnionDiscriminator struct { // Type is the enumeration type that discriminates members of the union. Must be an [EnumType]. Type Type `json:"type"` // Method is the name of the virtual field that discriminates members of the union. Method string `json:"method"` Enum *EnumType }
UnionDiscriminator specifies how members of the union are discriminated.
func (*UnionDiscriminator) Copy ¶
func (v *UnionDiscriminator) Copy() *UnionDiscriminator
Copy returns a copy of the UnionDiscriminator.
func (*UnionDiscriminator) Equal ¶
func (v *UnionDiscriminator) Equal(u *UnionDiscriminator) bool
EqualUnionDiscriminator returns true if V is equal to U.
func (*UnionDiscriminator) MarshalBinary ¶
func (v *UnionDiscriminator) MarshalBinary() ([]byte, error)
MarshalBinary marshals the UnionDiscriminator to bytes using binary.
func (*UnionDiscriminator) MarshalBinaryV2 ¶
func (v *UnionDiscriminator) MarshalBinaryV2(enc *binary.Encoder) error
MarshalBinary marshals the UnionDiscriminator to a binary.Encoder.
func (*UnionDiscriminator) MarshalJSON ¶
func (v *UnionDiscriminator) MarshalJSON() ([]byte, error)
MarshalBinary marshals the UnionDiscriminator to JSON.
func (*UnionDiscriminator) ResolveEnumTo ¶
func (u *UnionDiscriminator) ResolveEnumTo(s *ResolverSet, name string) *UnionDiscriminator
ResolveEnumTo resolves [UnionDiscriminator.Enum] to the given named type.
func (*UnionDiscriminator) ResolveTypeTo ¶
func (u *UnionDiscriminator) ResolveTypeTo(s *ResolverSet, name string) *UnionDiscriminator
ResolveTypeTo resolves [UnionDiscriminator.Type] to the given named type.
func (*UnionDiscriminator) UnmarshalBinary ¶
func (v *UnionDiscriminator) UnmarshalBinary(b []byte) error
UnmarshalBinary unmarshals the UnionDiscriminator from bytes using binary.
func (*UnionDiscriminator) UnmarshalBinaryV2 ¶
func (v *UnionDiscriminator) UnmarshalBinaryV2(dec *binary.Decoder) error
UnmarshalBinary unmarshals the UnionDiscriminator from a binary.Decoder.
func (*UnionDiscriminator) UnmarshalJSON ¶
func (v *UnionDiscriminator) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals the UnionDiscriminator from JSON.
type UnionMember ¶
type UnionMember struct { // Discriminator specifies which value of the discriminator enum corresponds to this union member. May be omitted if it can be inferred from the union and member type names. Discriminator string `json:"discriminator"` Type Union *UnionType Named Type DiscriminatorValue *EnumValue }
UnionMember specifies a member of a union.
func (*UnionMember) Copy ¶
func (v *UnionMember) Copy() *UnionMember
Copy returns a copy of the UnionMember.
func (*UnionMember) Equal ¶
func (v *UnionMember) Equal(u *UnionMember) bool
EqualUnionMember returns true if V is equal to U.
func (*UnionMember) GoType ¶
func (u *UnionMember) GoType() reflect.Type
GoType returns the reflect.Type of this type.
func (*UnionMember) MarshalBinary ¶
func (v *UnionMember) MarshalBinary() ([]byte, error)
MarshalBinary marshals the UnionMember to bytes using binary.
func (*UnionMember) MarshalBinaryV2 ¶
func (v *UnionMember) MarshalBinaryV2(enc *binary.Encoder) error
MarshalBinary marshals the UnionMember to a binary.Encoder.
func (*UnionMember) MarshalJSON ¶
func (v *UnionMember) MarshalJSON() ([]byte, error)
MarshalBinary marshals the UnionMember to JSON.
func (*UnionMember) ResolveTo ¶
func (u *UnionMember) ResolveTo(s *ResolverSet, name string) *UnionMember
ResolveTo resolves [UnionMember.Type] to the given named type.
func (*UnionMember) UnmarshalBinary ¶
func (v *UnionMember) UnmarshalBinary(b []byte) error
UnmarshalBinary unmarshals the UnionMember from bytes using binary.
func (*UnionMember) UnmarshalBinaryV2 ¶
func (v *UnionMember) UnmarshalBinaryV2(dec *binary.Decoder) error
UnmarshalBinary unmarshals the UnionMember from a binary.Decoder.
func (*UnionMember) UnmarshalJSON ¶
func (v *UnionMember) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals the UnionMember from JSON.
type UnionType ¶
type UnionType struct { TypeBase // Discriminator specifies how members of the union are discriminated. Discriminator *UnionDiscriminator `json:"discriminator"` // Members lists the members of the union. Members []*UnionMember `json:"members"` }
UnionType is a discriminated union of Type.
func (*UnionType) MarshalBinary ¶
MarshalBinary marshals the UnionType to bytes using binary.
func (*UnionType) MarshalBinaryV2 ¶
MarshalBinary marshals the UnionType to a binary.Encoder.
func (*UnionType) MarshalJSON ¶
MarshalBinary marshals the UnionType to JSON.
func (*UnionType) UnmarshalBinary ¶
UnmarshalBinary unmarshals the UnionType from bytes using binary.
func (*UnionType) UnmarshalBinaryV2 ¶
UnmarshalBinary unmarshals the UnionType from a binary.Decoder.
func (*UnionType) UnmarshalJSON ¶
UnmarshalJSON unmarshals the UnionType from JSON.
type Value ¶
type Value interface { Kind() ValueKind Bool(...string) (bool, bool) Number(...string) (float64, bool) String(...string) (string, bool) }
Value holds unstructured data.
func UnmarshalValueBinary ¶
UnmarshalValueBinary unmarshals a Value from bytes using binary.
func UnmarshalValueBinaryV2 ¶
UnmarshalValueBinary unmarshals a Value from a binary.Decoder.
func UnmarshalValueJSON ¶
UnmarshalValueJSON unmarshals a Value from JSON.
type ValueKind ¶
type ValueKind uint64
func ValueKindByName ¶
ValueKindByName looks up a ValueKind by name.
func (ValueKind) MarshalBinary ¶
MarshalBinary marshals the ValueKind to bytes using binary.
func (ValueKind) MarshalBinaryV2 ¶
MarshalBinary marshals the ValueKind to a binary.Encoder.
func (ValueKind) MarshalJSON ¶
MarshalBinary marshals the ValueKind to JSON.
func (*ValueKind) UnmarshalBinary ¶
UnmarshalBinary unmarshals the ValueKind from bytes using binary.
func (*ValueKind) UnmarshalBinaryV2 ¶
UnmarshalBinary unmarshals the ValueKind from a binary.Decoder.
func (*ValueKind) UnmarshalJSON ¶
UnmarshalJSON unmarshals the ValueKind from JSON.
Source Files
¶
- encode.go
- encode_binary.go
- encode_json.go
- field.go
- reflect.go
- resolve.go
- schema.go
- schema_gen.go
- schema_hooks.go
- type.go
- type_array.go
- type_base.go
- type_composite.go
- type_enum.go
- type_map.go
- type_methods.go
- type_pointer.go
- type_reference.go
- type_simple.go
- type_union.go
- types_gen.go
- utils.go
- value.go