Path is a sequence of protobuf reflection steps applied to some root protobuf message value to arrive at the current value. The first step must be a Root step.
type Path []Step
func (p Path) Index(i int) Step
Index returns the ith step in the path and supports negative indexing. A negative index starts counting from the tail of the Path such that -1 refers to the last step, -2 refers to the second-to-last step, and so on. It returns a zero Step value if the index is out-of-bounds.
func (p Path) String() string
String returns a structured representation of the path by concatenating the string representation of every path step.
Step is a union where only one step operation may be specified at a time. The different kinds of steps are specified by the constants defined for the StepKind type.
type Step struct {
// contains filtered or unexported fields
}
func AnyExpand(md protoreflect.MessageDescriptor) Step
AnyExpand describes expansion of a google.protobuf.Any message into a structured representation of the underlying message.
Within the context of Values, the type of the previous step value is always a google.protobuf.Any message, and the type of the current step value is always a message.
func FieldAccess(fd protoreflect.FieldDescriptor) Step
FieldAccess describes access of a field within a message. Extension field accesses are also represented using a FieldAccess and must be provided with a protoreflect.FieldDescriptor
Within the context of Values, the type of the previous step value is always a message, and the type of the current step value is determined by the field descriptor.
func ListIndex(i int) Step
ListIndex describes index of an element within a list.
Within the context of Values, the type of the previous, previous step value is always a message, the type of the previous step value is always a list, and the type of the current step value is determined by the field descriptor.
func MapIndex(k protoreflect.MapKey) Step
MapIndex describes index of an entry within a map. The key type is determined by field descriptor that the map belongs to.
Within the context of Values, the type of the previous previous step value is always a message, the type of the previous step value is always a map, and the type of the current step value is determined by the field descriptor.
func Root(md protoreflect.MessageDescriptor) Step
Root indicates the root message that a path is relative to. It should always (and only ever) be the first step in a path.
func UnknownAccess() Step
UnknownAccess describes access to the unknown fields within a message.
Within the context of Values, the type of the previous step value is always a message, and the type of the current step value is always a bytes type.
func (s Step) FieldDescriptor() protoreflect.FieldDescriptor
FieldDescriptor returns the field descriptor for FieldAccess steps, otherwise it returns nil.
func (s Step) Kind() StepKind
Kind reports which kind of step this is.
func (s Step) ListIndex() int
ListIndex returns the list index for ListIndex steps, otherwise it returns 0.
func (s Step) MapIndex() protoreflect.MapKey
MapIndex returns the map key for MapIndex steps, otherwise it returns an invalid map key.
func (s Step) MessageDescriptor() protoreflect.MessageDescriptor
MessageDescriptor returns the message descriptor for Root or AnyExpand steps, otherwise it returns nil.
func (s Step) String() string
StepKind identifies the kind of step operation. Each kind of step corresponds with some protobuf reflection operation.
type StepKind int
const ( // RootStep identifies a step as the Root step operation. RootStep StepKind // FieldAccessStep identifies a step as the FieldAccess step operation. FieldAccessStep // UnknownAccessStep identifies a step as the UnknownAccess step operation. UnknownAccessStep // ListIndexStep identifies a step as the ListIndex step operation. ListIndexStep // MapIndexStep identifies a step as the MapIndex step operation. MapIndexStep // AnyExpandStep identifies a step as the AnyExpand step operation. AnyExpandStep )
func (k StepKind) String() string
Values is a Path paired with a sequence of values at each step. The lengths of [Values.Path] and [Values.Values] must be identical. The first step must be a Root step and the first value must be a concrete message value.
type Values struct { Path Path Values []protoreflect.Value }
func (p Values) Index(i int) (out struct { Step Step Value protoreflect.Value })
Index returns the ith step and value and supports negative indexing. A negative index starts counting from the tail of the Values such that -1 refers to the last pair, -2 refers to the second-to-last pair, and so on.
func (p Values) Len() int
Len reports the length of the path and values. If the path and values have differing length, it returns the minimum length.
func (p Values) String() string
String returns a humanly readable representation of the path and last value. Do not depend on the output being stable.
For example:
(path.to.MyMessage).list_field[5].map_field["hello"] = {hello: "world"}