Documentation ¶
Index ¶
- Variables
- func Marshal(pb Message) ([]byte, error)
- func MarshalTo(pb Message, dest []byte) (int, error)
- func RegisterUnclonableType(typ reflect.Type, verbotenKind reflect.Kind)
- func Unmarshal(data []byte, pb Message) error
- type JSONPb
- func (*JSONPb) ContentType() string
- func (*JSONPb) Delimiter() []byte
- func (j *JSONPb) Marshal(v interface{}) ([]byte, error)
- func (j *JSONPb) NewDecoder(r io.Reader) gwruntime.Decoder
- func (j *JSONPb) NewEncoder(w io.Writer) gwruntime.Encoder
- func (j *JSONPb) Unmarshal(data []byte, v interface{}) error
- type Message
- type ProtoPb
- func (*ProtoPb) ContentType() string
- func (*ProtoPb) Delimiter() []byte
- func (*ProtoPb) Marshal(v interface{}) ([]byte, error)
- func (*ProtoPb) NewDecoder(r io.Reader) gwruntime.Decoder
- func (*ProtoPb) NewEncoder(w io.Writer) gwruntime.Encoder
- func (*ProtoPb) Unmarshal(data []byte, v interface{}) error
- type RecursiveAndUncloneable
- func (*RecursiveAndUncloneable) Descriptor() ([]byte, []int)
- func (m *RecursiveAndUncloneable) Marshal() (dAtA []byte, err error)
- func (m *RecursiveAndUncloneable) MarshalTo(dAtA []byte) (int, error)
- func (*RecursiveAndUncloneable) ProtoMessage()
- func (m *RecursiveAndUncloneable) Reset()
- func (m *RecursiveAndUncloneable) Size() (n int)
- func (m *RecursiveAndUncloneable) String() string
- func (m *RecursiveAndUncloneable) Unmarshal(dAtA []byte) error
- func (m *RecursiveAndUncloneable) XXX_DiscardUnknown()
- func (m *RecursiveAndUncloneable) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *RecursiveAndUncloneable) XXX_Merge(src proto.Message)
- func (m *RecursiveAndUncloneable) XXX_Size() int
- func (m *RecursiveAndUncloneable) XXX_Unmarshal(b []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLengthClone = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowClone = fmt.Errorf("proto: integer overflow") )
var Interceptor = func(_ Message) {}
Interceptor will be called with every proto before it is marshaled. Interceptor is not safe to modify concurrently with calls to Marshal.
Functions ¶
func Marshal ¶
Marshal encodes pb into the wire format. It is used throughout the code base to intercept calls to proto.Marshal.
func MarshalTo ¶
MarshalTo encodes pb into the wire format. It is used throughout the code base to intercept calls to pb.MarshalTo.
func RegisterUnclonableType ¶
RegisterUnclonableType registers a type as not being allowed for cloning. This is an added hack on top of the hack to allow clients of this package to disallow cloning of certain types which are not recursed into due to how oneof is implemented. In particular it may be the case that one of the implementations of an interface is unclonable. In this case, due to the type (rather than value) traversal, we'd not discover this fact.
See the comment on Clone.
func Unmarshal ¶
Unmarshal parses the protocol buffer representation in buf and places the decoded result in pb. If the struct underlying pb does not match the data in buf, the results can be unpredictable.
Unmarshal resets pb before starting to unmarshal, so any existing data in pb is always removed.
Types ¶
type JSONPb ¶
JSONPb is a gwruntime.Marshaler that uses github.com/gogo/protobuf/jsonpb.
func (*JSONPb) ContentType ¶
ContentType implements gwruntime.Marshaler.
func (*JSONPb) NewDecoder ¶
NewDecoder implements gwruntime.Marshaler.
func (*JSONPb) NewEncoder ¶
NewEncoder implements gwruntime.Marshaler.
type Message ¶
type Message interface { proto.Message MarshalTo(data []byte) (int, error) Unmarshal(data []byte) error Size() int }
Message extends the proto.Message interface with the MarshalTo and Size methods we tell gogoproto to generate for us.
func Clone ¶
Clone uses proto.Clone to return a deep copy of pb. It panics if pb recursively contains any instances of types which are known to be unsupported by proto.Clone.
This function and its associated lint (see build/style_test.go) exist to ensure we do not attempt to proto.Clone types which are not supported by proto.Clone. This hackery is necessary because proto.Clone gives no direct indication that it has incompletely cloned a type; it merely logs to standard output (see https://github.com/golang/protobuf/blob/89238a3/proto/clone.go#L204).
The concrete case against which this is currently guarding may be resolved upstream, see https://github.com/gogo/protobuf/issues/147.
type ProtoPb ¶
type ProtoPb struct{}
ProtoPb is a gwruntime.Marshaler that uses github.com/gogo/protobuf/proto.
func (*ProtoPb) ContentType ¶
ContentType implements gwruntime.Marshaler.
func (*ProtoPb) NewDecoder ¶
NewDecoder implements gwruntime.Marshaler.
func (*ProtoPb) NewEncoder ¶
NewEncoder implements gwruntime.Marshaler.
type RecursiveAndUncloneable ¶
type RecursiveAndUncloneable struct { R *RecursiveAndUncloneable `protobuf:"bytes,1,opt,name=r,proto3" json:"r,omitempty"` Uuid github_com_cockroachdb_cockroach_pkg_util_uuid.UUID `protobuf:"bytes,2,opt,name=uuid,proto3,customtype=github.com/ruiaylin/pgparser/utils/uuid.UUID" json:"uuid"` }
func (*RecursiveAndUncloneable) Descriptor ¶
func (*RecursiveAndUncloneable) Descriptor() ([]byte, []int)
func (*RecursiveAndUncloneable) Marshal ¶
func (m *RecursiveAndUncloneable) Marshal() (dAtA []byte, err error)
func (*RecursiveAndUncloneable) MarshalTo ¶
func (m *RecursiveAndUncloneable) MarshalTo(dAtA []byte) (int, error)
func (*RecursiveAndUncloneable) ProtoMessage ¶
func (*RecursiveAndUncloneable) ProtoMessage()
func (*RecursiveAndUncloneable) Reset ¶
func (m *RecursiveAndUncloneable) Reset()
func (*RecursiveAndUncloneable) Size ¶
func (m *RecursiveAndUncloneable) Size() (n int)
func (*RecursiveAndUncloneable) String ¶
func (m *RecursiveAndUncloneable) String() string
func (*RecursiveAndUncloneable) Unmarshal ¶
func (m *RecursiveAndUncloneable) Unmarshal(dAtA []byte) error
func (*RecursiveAndUncloneable) XXX_DiscardUnknown ¶
func (m *RecursiveAndUncloneable) XXX_DiscardUnknown()
func (*RecursiveAndUncloneable) XXX_Marshal ¶
func (m *RecursiveAndUncloneable) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*RecursiveAndUncloneable) XXX_Merge ¶
func (m *RecursiveAndUncloneable) XXX_Merge(src proto.Message)
func (*RecursiveAndUncloneable) XXX_Size ¶
func (m *RecursiveAndUncloneable) XXX_Size() int
func (*RecursiveAndUncloneable) XXX_Unmarshal ¶
func (m *RecursiveAndUncloneable) XXX_Unmarshal(b []byte) error