Documentation
¶
Index ¶
- func IsComponentValid(component Component, jsonSchemaBytes []byte) (bool, error)
- func IsSchemaValid(jsonSchemaBytes1 []byte, jsonSchemaBytes2 []byte) (bool, error)
- func SerializeComponentSchema(component Component) ([]byte, error)
- type Component
- type ComponentMetadata
- type ComponentOption
- type TypeID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsComponentValid ¶
func IsSchemaValid ¶
Types ¶
type Component ¶
type Component interface { // Name returns the name of the component. Name() string }
type ComponentMetadata ¶
type ComponentMetadata interface { // SetID sets the ID of this component. It must only be set once SetID(TypeID) error // ID returns the ID of the component. ID() TypeID // New returns the marshaled bytes of the default value for the component struct. New() ([]byte, error) Encode(any) ([]byte, error) Decode([]byte) (any, error) Name() string GetSchema() []byte }
ComponentMetadata is a high level representation of a user defined component struct.
func NewComponentMetadata ¶
func NewComponentMetadata[T Component](opts ...ComponentOption[T]) (ComponentMetadata, error)
NewComponentMetadata creates a new component type. The function is used to create a new component of the type.
type ComponentOption ¶
type ComponentOption[T any] func(c *componentMetadata[T]) //revive:disable-line:exported
ComponentOption is a type that can be passed to NewComponentMetadata to augment the creation of the component type.
func WithDefault ¶
func WithDefault[T any](defaultVal T) ComponentOption[T]
WithDefault updated the created componentMetadata with a default value.
Click to show internal directories.
Click to hide internal directories.