Documentation ¶
Index ¶
- Variables
- type Buffer
- func (p *Buffer) Bytes() []byte
- func (p *Buffer) DecodeFixed32() (x uint64, err error)
- func (p *Buffer) DecodeFixed64() (x uint64, err error)
- func (p *Buffer) DecodeRawBytes(alloc bool) (buf []byte, err error)
- func (p *Buffer) DecodeStringBytes() (s string, err error)
- func (p *Buffer) DecodeVarint() (x uint64, err error)
- func (p *Buffer) DecodeZigzag32() (x uint64, err error)
- func (p *Buffer) DecodeZigzag64() (x uint64, err error)
- func (p *Buffer) InspectWithoutSchema(verbose bool, raw []byte, w io.Writer) error
- func (p *Buffer) Reset()
- func (p *Buffer) SetBuf(s []byte)
- type Decoder
- type Definition
- func (d *Definition) AddEnum(pkg string, name string, enu *pp.Enum)
- func (d *Definition) AddMessage(pkg string, name string, message *pp.Message)
- func (d *Definition) Enum(pkg string, name string) (e *pp.Enum, ok bool)
- func (d *Definition) Message(pkg string, name string) (m *pp.Message, ok bool)
- func (d *Definition) MessagesInPackage(pkg string) (list []*pp.Message)
- func (d *Definition) Package(filename string) (pkg string, ok bool)
- func (d *Definition) ReadFile(filename string) error
- func (d *Definition) ReadFrom(filename string, reader io.Reader) error
- type Inspector
- func (p *Inspector) InspectWithoutSchema(verbose bool, raw []byte, w io.Writer) error
- func (p *Inspector) ReadSchemaFromFile(f string) error
- func (p *Inspector) ReadSchemaFromReader(f string, r io.Reader) error
- func (p *Inspector) ToMapWithSchema(pkg, name string, raw []byte) (map[string]interface{}, error)
- func (p *Inspector) ToMapWithSchemaByDefinition(d *Definition, pkg, name string, raw []byte) (map[string]interface{}, error)
Constants ¶
This section is empty.
Variables ¶
var ErrEndOfMessage = errors.New("end of message reached")
ErrEndOfMessage signals the decoder that a full message has been decoded
var ErrInternalBadWireType = errors.New("Buffer: bad wiretype for oneof")
ErrInternalBadWireType is returned by generated code when an incorrect wire type is encountered. It does not get returned to user code.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
A Buffer is a buffer manager for marshaling and unmarshaling protocol buffers. It may be reused between invocations to reduce memory usage. It is not necessary to use a Buffer; the global functions Marshal and Unmarshal create a temporary Buffer and are fine for most applications.
func NewBuffer ¶
NewBuffer allocates a new Buffer and initializes its internal data to the contents of the argument slice.
func (*Buffer) DecodeFixed32 ¶
DecodeFixed32 reads a 32-bit integer from the Buffer. This is the format for the fixed32, sfixed32, and float protocol buffer types.
func (*Buffer) DecodeFixed64 ¶
DecodeFixed64 reads a 64-bit integer from the Buffer. This is the format for the fixed64, sfixed64, and double protocol buffer types.
func (*Buffer) DecodeRawBytes ¶
DecodeRawBytes reads a count-delimited byte buffer from the Buffer. This is the format used for the bytes protocol buffer type and for embedded messages.
func (*Buffer) DecodeStringBytes ¶
DecodeStringBytes reads an encoded string from the Buffer. This is the format used for the proto2 string type.
func (*Buffer) DecodeVarint ¶
DecodeVarint reads a varint-encoded integer from the Buffer. This is the format for the int32, int64, uint32, uint64, bool, and enum protocol buffer types.
func (*Buffer) DecodeZigzag32 ¶
DecodeZigzag32 reads a zigzag-encoded 32-bit integer from the Buffer. This is the format used for the sint32 protocol buffer type.
func (*Buffer) DecodeZigzag64 ¶
DecodeZigzag64 reads a zigzag-encoded 64-bit integer from the Buffer. This is the format used for the sint64 protocol buffer type.
func (*Buffer) InspectWithoutSchema ¶
InspectWithoutSchema inspects raw protobuf binary data and write to w
type Decoder ¶ added in v0.1.4
type Decoder struct {
// contains filtered or unexported fields
}
func NewDecoder ¶ added in v0.1.4
func NewDecoder(d *Definition, b *Buffer) *Decoder
type Definition ¶ added in v0.1.4
type Definition struct {
// contains filtered or unexported fields
}
Definition holds the protobuf definition
func NewDefinition ¶ added in v0.1.4
func NewDefinition() *Definition
func (*Definition) AddEnum ¶ added in v0.1.4
func (d *Definition) AddEnum(pkg string, name string, enu *pp.Enum)
AddEnum adds the Enum
func (*Definition) AddMessage ¶ added in v0.1.4
func (d *Definition) AddMessage(pkg string, name string, message *pp.Message)
AddMessage adds the message
func (*Definition) MessagesInPackage ¶ added in v0.1.4
func (d *Definition) MessagesInPackage(pkg string) (list []*pp.Message)
MessagesInPackage returns the messages
func (*Definition) Package ¶ added in v0.1.4
func (d *Definition) Package(filename string) (pkg string, ok bool)
Package returns the proto package name as declared in the proto filename.
func (*Definition) ReadFile ¶ added in v0.1.4
func (d *Definition) ReadFile(filename string) error
ReadFile reads the proto definition from a filename.
type Inspector ¶
type Inspector struct {
// contains filtered or unexported fields
}
Inspector represents the protobuf inspector
func NewInspector ¶
func NewInspector() *Inspector
NewInspector returns the inspector to inpsect protobuf
func (*Inspector) InspectWithoutSchema ¶
InspectWithoutSchema inspects raw protobuf binary data and write to w
func (*Inspector) ReadSchemaFromFile ¶
ReadSchemaFromFile reads scheam from file.
func (*Inspector) ReadSchemaFromReader ¶
ReadSchemaFromReader reads schema from reader which named f.
func (*Inspector) ToMapWithSchema ¶
ToMapWithSchema maps raw bytes to map[string]interface{} by self definition
func (*Inspector) ToMapWithSchemaByDefinition ¶ added in v0.1.4
func (p *Inspector) ToMapWithSchemaByDefinition(d *Definition, pkg, name string, raw []byte) (map[string]interface{}, error)
ToMapWithSchema maps raw bytes to map[string]interface{} by specified definition