1package runtime 2 3import ( 4 "io" 5) 6 7// Marshaler defines a conversion between byte sequence and gRPC payloads / fields. 8type 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. 19 ContentType() string 20} 21 22// Decoder decodes a byte sequence 23type Decoder interface { 24 Decode(v interface{}) error 25} 26 27// Encoder encodes gRPC payloads / fields into byte sequence. 28type Encoder interface { 29 Encode(v interface{}) error 30} 31 32// DecoderFunc adapts an decoder function into Decoder. 33type DecoderFunc func(v interface{}) error 34 35// Decode delegates invocations to the underlying function itself. 36func (f DecoderFunc) Decode(v interface{}) error { return f(v) } 37 38// EncoderFunc adapts an encoder function into Encoder 39type EncoderFunc func(v interface{}) error 40 41// Encode delegates invocations to the underlying function itself. 42func (f EncoderFunc) Encode(v interface{}) error { return f(v) } 43 44// Delimited defines the streaming delimiter. 45type Delimited interface { 46 // Delimiter returns the record seperator for the stream. 47 Delimiter() []byte 48} 49