Documentation ¶
Overview ¶
Package protobuf provides a Marsha implementation for Protocol Buffers backed by `*.pb.go` files pre-generated by `protoc`.
Index ¶
- Variables
- type Marsha
- func (m *Marsha) MarshalPrimitive(_ interface{}) ([]byte, error)
- func (m *Marsha) MarshalStruct(p marsha.StructPtr) ([]byte, error)
- func (m *Marsha) MarshalStructSlice(_ marsha.StructSlicePtr) ([]byte, error)
- func (m *Marsha) NewDecoder(_ io.Reader) marsha.Decoder
- func (m *Marsha) NewEncoder(_ io.Writer) marsha.Encoder
- func (m *Marsha) UnmarshalPrimitive(_ []byte, _ interface{}) (int, error)
- func (m *Marsha) UnmarshalStruct(bin []byte, p marsha.StructPtr) (read int, err error)
- func (m *Marsha) UnmarshalStructSlice(_ []byte, _ marsha.StructSlicePtr) (int, error)
- type Struct
- type StructPtr
- type Test
- type Test2
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotPBStructPtr = errors.New("not a protobuf.StructPtr") ErrWrongPBType = errors.New("wrong protocol buffers type") )
View Source
var File_test2_proto protoreflect.FileDescriptor
View Source
var File_test_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type Marsha ¶ added in v0.0.2
type Marsha struct{}
Marsha is a `marsha.Marsha` implementation for Protocol Buffers backed by `*.pb.go` files pre-generated by `protoc`. Only `MarshalStruct` and `UnmarshalStruct` are supported by this implementation because of the limitation of Protocol Buffers.
func (*Marsha) MarshalPrimitive ¶ added in v0.0.2
Not implemented
func (*Marsha) MarshalStruct ¶ added in v0.0.2
func (*Marsha) MarshalStructSlice ¶ added in v0.0.2
Not implemented
func (*Marsha) NewDecoder ¶ added in v0.0.2
Not implemented
func (*Marsha) NewEncoder ¶ added in v0.0.2
Not implemented
func (*Marsha) UnmarshalPrimitive ¶ added in v0.0.2
Not implemented
func (*Marsha) UnmarshalStruct ¶ added in v0.0.2
type StructPtr ¶
type StructPtr interface { marsha.Struct // EmptyPB should return an empty corresponding `proto.Message`. EmptyPB() proto.Message // LoadPB should load data from `m` into the Struct this StructPtr points to. LoadPB(m proto.Message) error // PB should return a corresponding `proto.Message` filled with data of the Struct this StructPtr points to. PB() proto.Message }
type Test ¶
type Test struct { Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` // contains filtered or unexported fields }
func (*Test) Descriptor
deprecated
func (*Test) ProtoMessage ¶
func (*Test) ProtoMessage()
func (*Test) ProtoReflect ¶
func (x *Test) ProtoReflect() protoreflect.Message
type Test2 ¶
type Test2 struct { Data2 int32 `protobuf:"varint,1,opt,name=data2,proto3" json:"data2,omitempty"` // contains filtered or unexported fields }
func (*Test2) Descriptor
deprecated
func (*Test2) ProtoMessage ¶
func (*Test2) ProtoMessage()
func (*Test2) ProtoReflect ¶
func (x *Test2) ProtoReflect() protoreflect.Message
Click to show internal directories.
Click to hide internal directories.