Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶
Marshal traverses the value v recursively and returns the protocol buffer encoding of v. The struct underlying v must be a pointer.
Marshal currently encodes all visible field, which does not allow distinction between 'required' and 'optional' fields. Marshal ignores unsupported struct field types.
The returned slice may be a sub- slice of data if data was large enough to hold the entire encoded block. Otherwise, a newly allocated slice will be returned.
func Unmarshal ¶
Unmarshal parses the protocol buffer representation in data and places the decoded result in v. If the struct underlying v does not match the data, the results can be unpredictable.
Unmarshal uses the inverse of the encodings that Marshal uses, allocating slices and pointers as necessary.
func UnmarshalUnsafe ¶
UnmarshalUnsafe parses the protocol buffer representation in data and places the decoded result in v. If the struct underlying v does not match the data, the results can be unpredictable.
UnmarshalUnsafe uses the inverse of the encodings that Marshal uses, allocating slices and pointers as necessary.
UnmarshalUnsafe does not copy raw byte slices. Most code should use Unmarshal instead.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder manages the receipt of type and data information read from the remote side of a connection.
func NewDecoder ¶
NewDecoder returns a new decoder that reads from the io.Reader.
Max defines the maximum size that can be read, if max is 0, the maximum message size is not checked.
func (*Decoder) Decode ¶
Decode first reads the varint encoded message size and then reads the next value from the input stream and stores it in the data represented by the empty interface value. If v is nil, the value will be discarded. Otherwise, the value underlying v must be a pointer to the correct type for the next data item received.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder manages the transmission of type and data information to the other side of a connection.
func NewEncoder ¶
NewEncoder returns a new encoder that will transmit on the io.Writer.
Max defines the maximum size that can be transmitted, if max is 0, the maximum message size is not checked.
func (*Encoder) Encode ¶
Encode transmits the data item represented by the empty interface value, guaranteeing that all necessary type information has been transmitted first.
Encode first writes the varint encoded message size, traverses the value v recursively and writes the Protocol Buffer encoding of v. The struct underlying v must be a pointer.
Encode currently encodes all visible field and ignores unsupported Protocol Buffer struct field types.