7 // Marshaler defines a conversion between byte sequence and gRPC payloads / fields.
8 type Marshaler interface {
9 // Marshal marshals "v" into byte sequence.
10 Marshal(v interface{}) ([]byte, error)
11 // Unmarshal unmarshals "data" into "v".
12 // "v" must be a pointer value.
13 Unmarshal(data []byte, v interface{}) error
14 // NewDecoder returns a Decoder which reads byte sequence from "r".
15 NewDecoder(r io.Reader) Decoder
16 // NewEncoder returns an Encoder which writes bytes sequence into "w".
17 NewEncoder(w io.Writer) Encoder
18 // ContentType returns the Content-Type which this marshaler is responsible for.
22 // Decoder decodes a byte sequence
23 type Decoder interface {
24 Decode(v interface{}) error
27 // Encoder encodes gRPC payloads / fields into byte sequence.
28 type Encoder interface {
29 Encode(v interface{}) error
32 // DecoderFunc adapts an decoder function into Decoder.
33 type DecoderFunc func(v interface{}) error
35 // Decode delegates invocations to the underlying function itself.
36 func (f DecoderFunc) Decode(v interface{}) error { return f(v) }
38 // EncoderFunc adapts an encoder function into Encoder
39 type EncoderFunc func(v interface{}) error
41 // Encode delegates invocations to the underlying function itself.
42 func (f EncoderFunc) Encode(v interface{}) error { return f(v) }
44 // Delimited defines the streaming delimiter.
45 type Delimited interface {
46 // Delimiter returns the record seperator for the stream.