inspector

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEndOfMessage = errors.New("end of message reached")

ErrEndOfMessage signals the decoder that a full message has been decoded

View Source
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

func NewBuffer(e []byte) *Buffer

NewBuffer allocates a new Buffer and initializes its internal data to the contents of the argument slice.

func (*Buffer) Bytes

func (p *Buffer) Bytes() []byte

Bytes returns the contents of the Buffer.

func (*Buffer) DecodeFixed32

func (p *Buffer) DecodeFixed32() (x uint64, err error)

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

func (p *Buffer) DecodeFixed64() (x uint64, err error)

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

func (p *Buffer) DecodeRawBytes(alloc bool) (buf []byte, err error)

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

func (p *Buffer) DecodeStringBytes() (s string, err error)

DecodeStringBytes reads an encoded string from the Buffer. This is the format used for the proto2 string type.

func (*Buffer) DecodeVarint

func (p *Buffer) DecodeVarint() (x uint64, err error)

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

func (p *Buffer) DecodeZigzag32() (x uint64, err error)

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

func (p *Buffer) DecodeZigzag64() (x uint64, err error)

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

func (p *Buffer) InspectWithoutSchema(verbose bool, raw []byte, w io.Writer) error

InspectWithoutSchema inspects raw protobuf binary data and write to w

func (*Buffer) Reset

func (p *Buffer) Reset()

Reset resets the Buffer, ready for marshaling a new protocol buffer.

func (*Buffer) SetBuf

func (p *Buffer) SetBuf(s []byte)

SetBuf replaces the internal buffer with the slice, ready for unmarshaling the contents of the slice.

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

func (*Decoder) Decode added in v0.1.4

func (d *Decoder) Decode(pkg, t string) (map[string]interface{}, error)

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) Enum added in v0.1.4

func (d *Definition) Enum(pkg string, name string) (e *pp.Enum, ok bool)

Enum returns the enum

func (*Definition) Message added in v0.1.4

func (d *Definition) Message(pkg string, name string) (m *pp.Message, ok bool)

Message returns 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.

func (*Definition) ReadFrom added in v0.1.4

func (d *Definition) ReadFrom(filename string, reader io.Reader) error

ReadFrom reads from reader which named 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

func (p *Inspector) InspectWithoutSchema(verbose bool, raw []byte, w io.Writer) error

InspectWithoutSchema inspects raw protobuf binary data and write to w

func (*Inspector) ReadSchemaFromFile

func (p *Inspector) ReadSchemaFromFile(f string) error

ReadSchemaFromFile reads scheam from file.

func (*Inspector) ReadSchemaFromReader

func (p *Inspector) ReadSchemaFromReader(f string, r io.Reader) error

ReadSchemaFromReader reads schema from reader which named f.

func (*Inspector) ToMapWithSchema

func (p *Inspector) ToMapWithSchema(pkg, name string, raw []byte) (map[string]interface{}, error)

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

Jump to

Keyboard shortcuts

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