Documentation
¶
Index ¶
- Variables
- func DecodeTLBCellToAny(c *cell.Cell, tlbs tvm.TLBMap) (any, error)
- func DecodeTLBStructKeys(v any, tlbs tvm.TLBMap) ([]string, error)
- func DecodeTLBStructToJSON(v any, tlbs tvm.TLBMap) (string, map[string]any, error)
- func DecodeTLBValToJSON(v any, tlbs tvm.TLBMap) (string, any, error)
- func EnsureTLBStructPointer(value any) (any, error)
- type MessageEnvelope
- func (e *MessageEnvelope[T]) LoadDecoded(r tvm.ContractTLBRegistry) error
- func (e *MessageEnvelope[T]) LoadFromCell(slice *cell.Slice) error
- func (e MessageEnvelope[T]) MarshalJSON() ([]byte, error)
- func (e MessageEnvelope[T]) ToCell() (*cell.Cell, error)
- func (e *MessageEnvelope[T]) UnmarshalJSON(data []byte) error
- type MessageMeta
- type NonFatalResolverError
- type Resolver
- type ResolverChecker
- type ResolverKeyProvider
- type ResolverRegistry
- type TypedResolver
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownMessage = errors.New("unknown message type")
Functions ¶
func DecodeTLBStructKeys ¶
Returns ordered keys based TL-B annotated struct type
func DecodeTLBStructToJSON ¶
func EnsureTLBStructPointer ¶
EnsureTLBStructPointer ensures that the provided value is a pointer to a TL-B struct or struct itself.
Types ¶
type MessageEnvelope ¶
type MessageEnvelope[T any] struct { Metadata MessageMeta `json:"metadata"` Payload json.RawMessage `json:"payload"` Cell *cell.Cell `json:"-"` Value T `json:"-"` }
MessageEnvelope is the JSON-friendly representation of a TL-B message. The generic type parameter T represents the specific message type being wrapped.
func MustWrapMessage ¶
func MustWrapMessage[T any](contract string, val T) *MessageEnvelope[T]
func WrapMessage ¶
func WrapMessage[T any](contract string, val T) (*MessageEnvelope[T], error)
WrapMessage prepares a type-safe envelope for the provided TL-B message.
func (*MessageEnvelope[T]) LoadDecoded ¶
func (e *MessageEnvelope[T]) LoadDecoded(r tvm.ContractTLBRegistry) error
LoadFromRegistry attempts to populate the Value T field from the Payload or Cell using the provided registry.
func (*MessageEnvelope[T]) LoadFromCell ¶
func (e *MessageEnvelope[T]) LoadFromCell(slice *cell.Slice) error
func (MessageEnvelope[T]) MarshalJSON ¶
func (e MessageEnvelope[T]) MarshalJSON() ([]byte, error)
MarshalJSON ensures we persist the cached payload bytes when present.
func (*MessageEnvelope[T]) UnmarshalJSON ¶
func (e *MessageEnvelope[T]) UnmarshalJSON(data []byte) error
UnmarshalJSON populates the envelope metadata and rebuilds the typed value.
type MessageMeta ¶
type MessageMeta struct {
Contract string
Opcode uint64
// Go runtime type information
TypeName string
GoType reflect.Type
}
MessageMeta keeps the information required to serialize/deserialize TL-B messages.
func NewMessageMeta ¶
func NewMessageMeta(contract string, typ reflect.Type) (MessageMeta, error)
func NewMessageMetaFromValue ¶
func NewMessageMetaFromValue(contract string, v any) (MessageMeta, error)
func (MessageMeta) QualifiedKey ¶
func (m MessageMeta) QualifiedKey() string
type NonFatalResolverError ¶
type NonFatalResolverError struct {
// contains filtered or unexported fields
}
NonFatalResolverError indicates that resolution error is non-fatal and the resolver should be skipped
func NewNonFatalResolverError ¶
func NewNonFatalResolverError(cause error) NonFatalResolverError
func (NonFatalResolverError) Error ¶
func (e NonFatalResolverError) Error() string
type ResolverChecker ¶
ResolverChecker checks if a resolver can handle a given input
type ResolverKeyProvider ¶
type ResolverKeyProvider interface {
Key() string
}
ResolverKeyProvider provides a key for identifying the resolver
type ResolverRegistry ¶
type ResolverRegistry struct {
// contains filtered or unexported fields
}
ResolverRegistry manages a collection of typed resolvers
func NewResolverRegistry ¶
func NewResolverRegistry(resolvers ...TypedResolver) *ResolverRegistry
NewResolverRegistry creates a new ResolverRegistry with optional initial resolvers
func (*ResolverRegistry) Register ¶
func (r *ResolverRegistry) Register(resolver TypedResolver)
Register adds a resolver to the registry
type TypedResolver ¶
type TypedResolver interface {
// ResolverChecker.CanResolve checks if this resolver can handle the given input type
ResolverChecker[any]
// Resolver.Resolve performs the resolution, returning the resolved value
Resolver[any, any]
// ResolverKeyProvider.Key returns the unique key for this resolver
ResolverKeyProvider
// InputType returns the reflect.Type this resolver accepts
InputType() reflect.Type
// OutputType returns the reflect.Type this resolver produces
OutputType() reflect.Type
}
TypedResolver wraps a resolver with type information for dynamic dispatch
func NewTypedResolver ¶
func NewTypedResolver[IN any, OUT any](resolver Resolver[IN, OUT]) TypedResolver
NewTypedResolver creates a TypedResolver from a generic Resolver
func NewTypedResolverWith ¶
func NewTypedResolverWith[IN any, OUT any](resolver Resolver[IN, OUT], key string) TypedResolver
NewTypedResolverWith creates a TypedResolver from a generic Resolver with a specified key