Documentation ¶
Index ¶
- Constants
- Variables
- type Result
- func (r Result) Bool() bool
- func (r Result) Bytes() []byte
- func (r Result) Exist() bool
- func (r Result) Fixed32() uint32
- func (r Result) Fixed64() uint64
- func (r Result) Float32() float32
- func (r Result) Float64() float64
- func (r Result) GetAll(pbNumbers ...protowire.Number) []Result
- func (r Result) GetIter(resultSink func(Result) bool, pbNumbers ...protowire.Number) (err error)
- func (r Result) GetOne(pbNumbers ...protowire.Number) (result Result)
- func (r Result) Int32() int32
- func (r Result) Int64() int64
- func (r Result) IterFields(pbNumber protowire.Number, resultSink func(r Result) bool) (int, error)
- func (r Result) SFixed32() int32
- func (r Result) SFixed64() int64
- func (r Result) Sint32() int32
- func (r Result) Sint64() int64
- func (r Result) String() string
- func (r Result) Uint32() uint32
- func (r Result) Uint64() uint64
- func (r Result) Unpack(itemType protowire.Type) []Result
- func (r Result) UnpackFixed32() []Result
- func (r Result) UnpackFixed64() []Result
- func (r Result) UnpackVarint() []Result
Constants ¶
const InvalidWireType protowire.Type = -1
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct { // WireType the fields wire type enumerate // type==0, used for: int32, int64, uint32, uint64, sint32, sint64, bool, enum // type==1, used for: fixed64, sfixed64, double // type==5, used for: fixed32, sfixed32, float // type==2, used for: string, bytes, embedded messages, packed repeated fields WireType protowire.Type Varint uint64 Raw []byte // message without length header }
func GetAll ¶
GetAll gets all the values by the given field numbers. `pbNumbers` indicates the path to retrieve the desired field.
func GetOne ¶
GetOne gets the first value by the given field numbers. `pbNumbers` indicates the path to retrieve the desired field. **Attention**: when the field is repeated in proto2, the first item is returned.
In proto3 or proto2 packed mode, the first packed group is returned, and the UnpackVarint / UnpackFixed32 / UnpackFixed64 should be called to break a single length-delimited frame into multiple Results.
func (Result) Bytes ¶
Bytes parses the result as a byte slice. When the wire type is not BytesType, nil will be returned.
func (Result) Fixed64 ¶
Fixed64 parses the 64-bit raw bytes into uint64. When the wire type is not Fixed64Type, it returns 0.
func (Result) Float64 ¶
Float64 parses the 64-bit raw bytes into float64. When the wire type is not Fixed64Type, it returns 0.
func (Result) GetAll ¶
GetAll unlike GetOne, GetAll returns all the values by the given field numbers.
func (Result) GetIter ¶
GetIter like GetAll, gets all the values until the resultSink returns false. Both GetOne and GetAll are implemented by this function.
func (Result) GetOne ¶
GetOne gets the first field by the given field numbers. `pbNumbers` indicates the path to retrieve the desired field. There is no heap-memory allocation in this function.
**Attention**: when the field is repeated in proto2, the first item is returned.
In proto3 or proto2 packed mode, the first packed group is returned, and the UnpackVarint / UnpackFixed32 / UnpackFixed64 should be called to break a single length-delimited frame into multiple Results.
func (Result) IterFields ¶
IterFields read through the binary data stored in r.Raw field-by-field, skipping all the fields not interested in.
func (Result) SFixed64 ¶
SFixed64 parses the 64-bit raw bytes into int64. When the wire type is not Fixed64Type, it returns 0.
func (Result) String ¶
String parses the result as a string. When the wire type is not BytesType, empty string will be returned.
func (Result) Unpack ¶
Unpack make packed scalars into []Result. In proto2, repeated fields of primitive numeric types can be declared as packed. In proto3, the fields are packed by default.
func (Result) UnpackFixed32 ¶
UnpackFixed32 unpacks the length-delimited fixed32-encoded binary data into separate results.
func (Result) UnpackFixed64 ¶
UnpackFixed64 unpacks the length-delimited fixed64-encoded binary data into separate results.
func (Result) UnpackVarint ¶
UnpackVarint unpacks the length-delimited varint-encoded binary data into separate results.