protodesc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package protodesc provides bidirectional conversion between this project's descriptor types and the google.protobuf.FileDescriptorProto wire format.

ToFileDescriptorProto converts a FileDescriptorAccessor into a dynamic message conforming to google.protobuf.FileDescriptorProto, which can then be marshaled to wire format for interoperability with other protobuf tools.

FromFileDescriptorProto converts a wire-format FileDescriptorProto (as a proto.Message) back into this project's FileDescriptor type.

The FileDescriptorProto message descriptor is built programmatically using the descriptor builder API rather than importing Google's descriptorpb, maintaining the project's zero-dependency policy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromFileDescriptorProto

func FromFileDescriptorProto(msg proto.Message) (*descriptor.FileDescriptor, error)

FromFileDescriptorProto converts a wire-format FileDescriptorProto (as a proto.Message) into this project's descriptor type. The input must be a dynamicpb.Message conforming to the FileDescriptorProto schema.

func Register

func Register()

Register builds all descriptor proto message descriptors in dependency order. Under standard Go this is handled by init(); under TinyGo consumers must call Register() explicitly before using protodesc conversion functions.

func ToFileDescriptorProto

func ToFileDescriptorProto(fd descriptor.FileDescriptorAccessor) *dynamicpb.Message

ToFileDescriptorProto converts this project's file descriptor into a dynamic message conforming to google.protobuf.FileDescriptorProto.

Types

type ConvertError

type ConvertError struct {
	// Element describes the descriptor element being converted (e.g.
	// "message_type[0]", "field[2]", "MethodDescriptorProto name").
	Element string
	// Detail is a human-readable description of the failure.
	Detail string
	// Cause is the underlying error, if any.
	Cause error
}

ConvertError is a typed error returned when descriptor conversion fails. It includes the descriptor element context (e.g. "message_type[0]") and wraps an optional underlying cause.

func (*ConvertError) Error

func (e *ConvertError) Error() string

Error returns a human-readable message with the element context.

func (*ConvertError) Unwrap

func (e *ConvertError) Unwrap() error

Unwrap returns the underlying cause so that errors.Is and errors.As work.

Jump to

Keyboard shortcuts

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