Documentation ¶
Overview ¶
Package signature implements the interfaces, types, and utility functions that can be used by Guest and Host implementations of Scale Signatures.
Index ¶
- Constants
- Variables
- func ValidPrimitiveType(t string) bool
- type BoolArraySchema
- type BoolSchema
- type BytesArraySchema
- type BytesSchema
- type EnumArraySchema
- type EnumMapSchema
- type EnumReferenceSchema
- type EnumSchema
- type ModelReferenceArraySchema
- type ModelReferenceMapSchema
- type ModelReferenceSchema
- type ModelSchema
- type Number
- type NumberArraySchema
- type NumberLimitValidatorSchema
- type NumberMapSchema
- type NumberSchema
- type Schema
- func (s *Schema) Clone() (*Schema, error)
- func (s *Schema) CloneWithDisabledAccessorsValidatorsAndModifiers() (*Schema, error)
- func (s *Schema) Decode(data []byte) error
- func (s *Schema) Encode() ([]byte, error)
- func (s *Schema) HasCaseModifier() bool
- func (s *Schema) HasLengthValidator() bool
- func (s *Schema) HasLimitValidator() bool
- func (s *Schema) HasRegexValidator() bool
- func (s *Schema) Hash() ([]byte, error)
- func (s *Schema) SetHasCaseModifier(value bool)
- func (s *Schema) SetHasLengthValidator(value bool)
- func (s *Schema) SetHasLimitValidator(value bool)
- func (s *Schema) SetHasRegexValidator(value bool)
- type StringArraySchema
- type StringCaseModifierSchema
- type StringLengthValidatorSchema
- type StringMapSchema
- type StringRegexValidatorSchema
- type StringSchema
Constants ¶
const MasterTestingSchema = `` /* 5119-byte string literal not displayed */
const (
V1AlphaVersion = "v1alpha"
)
Variables ¶
var ( ValidLabel = regexp.MustCompile(`^[A-Za-z0-9]*$`) InvalidString = regexp.MustCompile(`[^A-Za-z0-9-.]`) )
Functions ¶
func ValidPrimitiveType ¶
Types ¶
type BoolArraySchema ¶
type BoolArraySchema struct { Name string `hcl:"name,label"` InitialSize uint32 `hcl:"initial_size,attr"` Accessor bool `hcl:"accessor,optional"` }
func (*BoolArraySchema) Validate ¶
func (s *BoolArraySchema) Validate(model *ModelSchema) error
type BoolSchema ¶
type BoolSchema struct { Name string `hcl:"name,label"` Default bool `hcl:"default,attr"` Accessor bool `hcl:"accessor,optional"` }
func (*BoolSchema) Validate ¶
func (s *BoolSchema) Validate(model *ModelSchema) error
type BytesArraySchema ¶
type BytesArraySchema struct { Name string `hcl:"name,label"` InitialSize uint32 `hcl:"initial_size,attr"` Accessor bool `hcl:"accessor,optional"` }
func (*BytesArraySchema) Validate ¶
func (s *BytesArraySchema) Validate(model *ModelSchema) error
type BytesSchema ¶
type BytesSchema struct { Name string `hcl:"name,label"` InitialSize uint32 `hcl:"initial_size,attr"` Accessor bool `hcl:"accessor,optional"` }
func (*BytesSchema) Validate ¶
func (s *BytesSchema) Validate(model *ModelSchema) error
type EnumArraySchema ¶
type EnumArraySchema struct { Name string `hcl:"name,label"` Reference string `hcl:"reference,attr"` InitialSize uint32 `hcl:"initial_size,attr"` Accessor bool `hcl:"accessor,optional"` }
func (*EnumArraySchema) Validate ¶
func (s *EnumArraySchema) Validate(model *ModelSchema) error
type EnumMapSchema ¶
type EnumMapSchema struct { Name string `hcl:"name,label"` Reference string `hcl:"reference,attr"` Value string `hcl:"value,attr"` Accessor bool `hcl:"accessor,optional"` }
func (*EnumMapSchema) Validate ¶
func (s *EnumMapSchema) Validate(model *ModelSchema) error
type EnumReferenceSchema ¶
type EnumReferenceSchema struct { Name string `hcl:"name,label"` Default string `hcl:"default,attr"` Reference string `hcl:"reference,attr"` Accessor bool `hcl:"accessor,optional"` }
func (*EnumReferenceSchema) Validate ¶
func (s *EnumReferenceSchema) Validate(model *ModelSchema, enums []*EnumSchema) error
type EnumSchema ¶
func (*EnumSchema) Normalize ¶
func (s *EnumSchema) Normalize()
func (*EnumSchema) Validate ¶
func (s *EnumSchema) Validate(knownEnums map[string]struct{}) error
type ModelReferenceArraySchema ¶
type ModelReferenceArraySchema struct { Name string `hcl:"name,label"` Reference string `hcl:"reference,attr"` InitialSize uint32 `hcl:"initial_size,attr"` Accessor bool `hcl:"accessor,optional"` }
func (*ModelReferenceArraySchema) Validate ¶
func (m *ModelReferenceArraySchema) Validate(model *ModelSchema) error
type ModelReferenceMapSchema ¶
type ModelReferenceMapSchema struct { Name string `hcl:"name,label"` Reference string `hcl:"reference,attr"` Value string `hcl:"value,attr"` Accessor bool `hcl:"accessor,optional"` }
func (*ModelReferenceMapSchema) Validate ¶
func (m *ModelReferenceMapSchema) Validate(model *ModelSchema) error
type ModelReferenceSchema ¶
type ModelReferenceSchema struct { Name string `hcl:"name,label"` Reference string `hcl:"reference,attr"` Accessor bool `hcl:"accessor,optional"` }
func (*ModelReferenceSchema) Validate ¶
func (m *ModelReferenceSchema) Validate(model *ModelSchema) error
type ModelSchema ¶
type ModelSchema struct { Name string `hcl:"name,label"` Description string `hcl:"description,optional"` Models []*ModelReferenceSchema `hcl:"model,block"` ModelArrays []*ModelReferenceArraySchema `hcl:"model_array,block"` Strings []*StringSchema `hcl:"string,block"` StringArrays []*StringArraySchema `hcl:"string_array,block"` StringMaps []*StringMapSchema `hcl:"string_map,block"` Bools []*BoolSchema `hcl:"bool,block"` BoolArrays []*BoolArraySchema `hcl:"bool_array,block"` Bytes []*BytesSchema `hcl:"bytes,block"` BytesArrays []*BytesArraySchema `hcl:"bytes_array,block"` Enums []*EnumReferenceSchema `hcl:"enum,block"` EnumArrays []*EnumArraySchema `hcl:"enum_array,block"` EnumMaps []*EnumMapSchema `hcl:"enum_map,block"` Int32s []*NumberSchema[int32] `hcl:"int32,block"` Int32Arrays []*NumberArraySchema[int32] `hcl:"int32_array,block"` Int32Maps []*NumberMapSchema[int32] `hcl:"int32_map,block"` Int64s []*NumberSchema[int64] `hcl:"int64,block"` Int64Arrays []*NumberArraySchema[int64] `hcl:"int64_array,block"` Int64Maps []*NumberMapSchema[int64] `hcl:"int64_map,block"` Uint32s []*NumberSchema[uint32] `hcl:"uint32,block"` Uint32Arrays []*NumberArraySchema[uint32] `hcl:"uint32_array,block"` Uint32Maps []*NumberMapSchema[uint32] `hcl:"uint32_map,block"` Uint64s []*NumberSchema[uint64] `hcl:"uint64,block"` Uint64Arrays []*NumberArraySchema[uint64] `hcl:"uint64_array,block"` Uint64Maps []*NumberMapSchema[uint64] `hcl:"uint64_map,block"` Float32s []*NumberSchema[float32] `hcl:"float32,block"` Float32Arrays []*NumberArraySchema[float32] `hcl:"float32_array,block"` Float64s []*NumberSchema[float64] `hcl:"float64,block"` Float64Arrays []*NumberArraySchema[float64] `hcl:"float64_array,block"` }
func (*ModelSchema) Normalize ¶
func (m *ModelSchema) Normalize()
func (*ModelSchema) Validate ¶
func (m *ModelSchema) Validate(knownModels map[string]struct{}, enums []*EnumSchema) error
type NumberArraySchema ¶
type NumberArraySchema[T Number] struct { Name string `hcl:"name,label"` InitialSize uint32 `hcl:"initial_size,attr"` Accessor *bool `hcl:"accessor,optional"` LimitValidator *NumberLimitValidatorSchema[T] `hcl:"limit_validator,block"` }
func (*NumberArraySchema[T]) Validate ¶
func (s *NumberArraySchema[T]) Validate(model *ModelSchema) error
type NumberLimitValidatorSchema ¶
type NumberLimitValidatorSchema[T Number] struct { Maximum *T `hcl:"max,optional"` Minimum *T `hcl:"min,optional"` }
type NumberMapSchema ¶
type NumberMapSchema[T Number] struct { Name string `hcl:"name,label"` Value string `hcl:"value,attr"` Accessor *bool `hcl:"accessor,optional"` LimitValidator *NumberLimitValidatorSchema[T] `hcl:"limit_validator,block"` }
func (*NumberMapSchema[T]) Validate ¶
func (s *NumberMapSchema[T]) Validate(model *ModelSchema) error
type NumberSchema ¶
type NumberSchema[T Number] struct { Name string `hcl:"name,label"` Default T `hcl:"default,attr"` Accessor *bool `hcl:"accessor,optional"` LimitValidator *NumberLimitValidatorSchema[T] `hcl:"limit_validator,block"` }
func (*NumberSchema[T]) Validate ¶
func (s *NumberSchema[T]) Validate(model *ModelSchema) error
type Schema ¶
type Schema struct { Version string `hcl:"version,attr"` Context string `hcl:"context,attr"` Enums []*EnumSchema `hcl:"enum,block"` Models []*ModelSchema `hcl:"model,block"` // contains filtered or unexported fields }
Schema is the top-level structure of a Scale Signature schema
func ReadSchema ¶
ReadSchema reads a Scale Signature schema from a file at the given path
func (*Schema) CloneWithDisabledAccessorsValidatorsAndModifiers ¶
CloneWithDisabledAccessorsValidatorsAndModifiers returns a clone of the schema with all accessors, validators, and modifiers disabled
func (*Schema) Decode ¶
Decode decodes the given byte slice into the Schema
Note: This function modifies the Schema in-place and validates/normalizes it as well.
func (*Schema) HasCaseModifier ¶
HasCaseModifier returns true if the schema has a case modifier
func (*Schema) HasLengthValidator ¶
HasLengthValidator returns true if the schema has a length validator
func (*Schema) HasLimitValidator ¶
HasLimitValidator returns true if the schema has a limit validator
func (*Schema) HasRegexValidator ¶
HasRegexValidator returns true if the schema has a regex validator
func (*Schema) SetHasCaseModifier ¶ added in v0.4.6
SetHasCaseModifier sets the hasCaseModifier flag
func (*Schema) SetHasLengthValidator ¶ added in v0.4.6
SetHasLengthValidator sets the hasLengthValidator flag
func (*Schema) SetHasLimitValidator ¶ added in v0.4.6
SetHasLimitValidator sets the hasLimitValidator flag
func (*Schema) SetHasRegexValidator ¶ added in v0.4.6
SetHasRegexValidator sets the hasRegexValidator flag
type StringArraySchema ¶
type StringArraySchema struct { Name string `hcl:"name,label"` InitialSize uint32 `hcl:"initial_size,attr"` Accessor *bool `hcl:"accessor,optional"` RegexValidator *StringRegexValidatorSchema `hcl:"regex_validator,block"` LengthValidator *StringLengthValidatorSchema `hcl:"length_validator,block"` CaseModifier *StringCaseModifierSchema `hcl:"caseModifier,block"` }
func (*StringArraySchema) Validate ¶
func (s *StringArraySchema) Validate(model *ModelSchema) error
type StringCaseModifierSchema ¶
type StringCaseModifierSchema struct {
Kind string `hcl:"kind,attr"`
}
type StringMapSchema ¶
type StringMapSchema struct { Name string `hcl:"name,label"` Value string `hcl:"value,attr"` Accessor *bool `hcl:"accessor,optional"` RegexValidator *StringRegexValidatorSchema `hcl:"regex_validator,block"` LengthValidator *StringLengthValidatorSchema `hcl:"length_validator,block"` CaseModifier *StringCaseModifierSchema `hcl:"caseModifier,block"` }
func (*StringMapSchema) Validate ¶
func (s *StringMapSchema) Validate(model *ModelSchema) error
type StringRegexValidatorSchema ¶
type StringRegexValidatorSchema struct {
Expression string `hcl:"expression,attr"`
}
type StringSchema ¶
type StringSchema struct { Name string `hcl:"name,label"` Default string `hcl:"default,attr"` Accessor *bool `hcl:"accessor,optional"` RegexValidator *StringRegexValidatorSchema `hcl:"regex_validator,block"` LengthValidator *StringLengthValidatorSchema `hcl:"length_validator,block"` CaseModifier *StringCaseModifierSchema `hcl:"case_modifier,block"` }
func (*StringSchema) Validate ¶
func (s *StringSchema) Validate(model *ModelSchema) error
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package converter generates a polyglot-encoded buffer from a signature schema and a data payload
|
Package converter generates a polyglot-encoded buffer from a signature schema and a data payload |