Documentation
¶
Overview ¶
Package proto contains an implementation of a protocol buffer parser.
Merging of fields and splitting of arrays are not supported by this parser for optimization reasons. Use the NoLatentAppendingOrMerging function to check whether the marshaled buffer conforms to the limitations.
TODO: defaults, maps and proto3 zero values
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NoLatentAppendingOrMerging ¶
func NoLatentAppendingOrMerging(parser ProtoParser) error
NoLatentAppendingOrMerging returns whether the current parser has some latent fields. Latent fields are those fields you have already seen on your walk, but then after seeing a different field you see this field again. This typically happens when the protocol buffer user created an object marshaled it and then merged it with another value.
Types ¶
type DescMap ¶
type DescMap interface { //GetRoot returns the root message that was used to create this map. GetRoot() *descriptor.DescriptorProto //LookupMessage returns the message descriptor of the field type. LookupMessage(field *descriptor.FieldDescriptorProto) *descriptor.DescriptorProto //LookupFields returns a map of field key to field descriptor in the message. LookupFields(msg *descriptor.DescriptorProto) map[uint64]*descriptor.FieldDescriptorProto }
DescMap is a map of the descriptor.FileDescriptorSet
func NewDescriptorMap ¶
func NewDescriptorMap(pkgName, msgName string, desc *descriptor.FileDescriptorSet) (DescMap, error)
NewDescriptorMap returns a map of the FileDescriptorSet starting at the message represented by the package name and message name.
type ProtoParser ¶
type ProtoParser interface { parser.Interface //Init initialises the parser with a marshaled protocol buffer. Init([]byte) error //Reset resets the parser to go back to the beginnig. Reset() error //Message returns the current message's descriptor. Message() *descriptor.DescriptorProto //Field returns the current field's descriptor. Field() *descriptor.FieldDescriptorProto }
ProtoParser represents a protocol buffer parser.
func NewProtoParser ¶ added in v0.4.0
func NewProtoParser(rootPackage, rootMessage string, desc *descriptor.FileDescriptorSet) (ProtoParser, error)
NewProtoParser returns a new protocol buffer parser the specific root message. When the value of a field name is requested this parser will return the field name using the String method.
Directories
¶
Path | Synopsis |
---|---|
Package prototests contains some structures and values that are useful for testing the protocol buffer parser.
|
Package prototests contains some structures and values that are useful for testing the protocol buffer parser. |