blob: 5938e238164c79df18105470b2fb0f458aee964c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package grpc
import "google.golang.org/grpc/encoding"
type rawMessage []byte
func (r rawMessage) Reset() {}
func (rawMessage) ProtoMessage() {}
func (rawMessage) String() string { return "rawMessage" }
type codec struct{ base encoding.Codec }
// Marshal returns the wire format of v. rawMessages would be returned without encoding.
func (c *codec) Marshal(v interface{}) ([]byte, error) {
if raw, ok := v.(rawMessage); ok {
return raw, nil
}
return c.base.Marshal(v)
}
// Unmarshal parses the wire format into v. rawMessages would not be unmarshalled.
func (c *codec) Unmarshal(data []byte, v interface{}) error {
if raw, ok := v.(*rawMessage); ok {
*raw = data
return nil
}
return c.base.Unmarshal(data, v)
}
// String return codec name.
func (c *codec) String() string {
return "raw:" + c.base.Name()
}
|