Documentation
¶
Overview ¶
Package protopath provides types for representing paths through a protobuf message tree. A Path is a sequence of Steps, where each Step describes a single navigation action: accessing a field by descriptor, indexing into a repeated field, looking up a map key, or expanding an Any message.
Paths are used by the protorange package to report the location of each visited node during message traversal.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Path ¶
type Path []Step
Path represents a location in a protobuf message tree as a sequence of Steps from the root message to a specific node.
type Step ¶
type Step struct {
// contains filtered or unexported fields
}
Step represents a single navigation step in a protobuf message tree. A step is one of four kinds: field access (by descriptor), list index, map key, or Any expansion. Use the constructor functions FieldAccess, ListIndex, MapKey, and AnyExpand to create Steps.
func AnyExpand ¶
func AnyExpand(md descriptor.MessageDescriptorAccessor) Step
AnyExpand returns a Step representing the expansion of a google.protobuf.Any message into its concrete message type.
func FieldAccess ¶
func FieldAccess(fd descriptor.FieldDescriptorAccessor) Step
FieldAccess returns a Step representing access to a message field by its descriptor.
func ListIndex ¶
ListIndex returns a Step representing access to a repeated field element at the given index.
func MapKey ¶
func MapKey(k protoreflect.MapKey) Step
MapKey returns a Step representing access to a map field entry by its key.
func (Step) FieldDescriptor ¶
func (s Step) FieldDescriptor() descriptor.FieldDescriptorAccessor
FieldDescriptor returns the field descriptor for a field access step, or nil if this step is not a field access.
func (Step) String ¶
String returns a human-readable representation of the step. Field access steps use the field name prefixed with a dot. List index steps use bracket notation. Map key steps use bracket notation with the key value. Any expand steps show the expanded message full name in parentheses.