component

package
v0.0.0-...-ba58dea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrComponentAlreadyRegistered = errors.New("component already registered")
View Source
var ErrMarshalInvalidType = errors.New("invalid component type")
View Source
var ErrMarshalerRequired = errors.New("marshaler is required")
View Source
var ErrProtoMessageAlreadyRegistered = errors.New("proto message already registered")
View Source
var ErrUnknownComponent = errors.New("unknown component")
View Source
var ErrUnknownProtoMessage = errors.New("unknown proto message")

Functions

func Register

func Register[T any, P proto.Message](marshaler Marshaler[T, P], options ...func(*metadataConfig)) error

func RegisterFatal

func RegisterFatal[T any, P proto.Message](marshaler Marshaler[T, P], options ...func(*metadataConfig))

func WithHidden

func WithHidden[T any](hidden bool) func(config *metadataConfig)

func WithReplicate

func WithReplicate[T any](replicate bool) func(config *metadataConfig)

Types

type Marshaler

type Marshaler[C any, P proto.Message] interface {
	MarshalProto(cmp C) (P, error)
	UnmarshalProto(msg P) (C, error)
}

type Metadata

type Metadata[C any, P proto.Message] struct {
	// contains filtered or unexported fields
}

func (Metadata[C, P]) IsHidden

func (m Metadata[C, P]) IsHidden() bool

func (Metadata[C, P]) MarshalProto

func (m Metadata[C, P]) MarshalProto(component C) (P, error)

func (Metadata[C, P]) MarshalProtoAny

func (m Metadata[C, P]) MarshalProtoAny(component any) (proto.Message, error)

func (Metadata[C, P]) ShouldReplicate

func (m Metadata[C, P]) ShouldReplicate() bool

func (Metadata[C, P]) UnmarshalProto

func (m Metadata[C, P]) UnmarshalProto(msg P) (C, error)

func (Metadata[C, P]) UnmarshalProtoAny

func (m Metadata[C, P]) UnmarshalProtoAny(msg proto.Message) (any, error)

type MetadataAny

type MetadataAny interface {
	MarshalProtoAny(any) (proto.Message, error)
	UnmarshalProtoAny(proto.Message) (any, error)
	ShouldReplicate() bool
	IsHidden() bool
}

func GetMetadata

func GetMetadata(component any) (MetadataAny, bool)

func GetMetadataType

func GetMetadataType(typ reflect.Type) (MetadataAny, bool)

func ListMetadata

func ListMetadata() []MetadataAny

func MarshalProto

func MarshalProto(cmp any) (proto.Message, MetadataAny, error)

func MarshalProtoAny

func MarshalProtoAny(cmp any) (*anypb.Any, MetadataAny, error)

func UnmarshalProto

func UnmarshalProto(msg proto.Message) (any, MetadataAny, error)

func UnmarshalProtoAny

func UnmarshalProtoAny(msg *anypb.Any) (any, MetadataAny, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL