Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message type identifier and 4 byte message length.
(src []byte)
| 18 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message |
| 19 | // type identifier and 4 byte message length. |
| 20 | func (dst *FunctionCallResponse) Decode(src []byte) error { |
| 21 | if len(src) < 4 { |
| 22 | return &invalidMessageFormatErr{messageType: "FunctionCallResponse"} |
| 23 | } |
| 24 | rp := 0 |
| 25 | resultSize := int(int32(binary.BigEndian.Uint32(src[rp:]))) |
| 26 | rp += 4 |
| 27 | |
| 28 | if resultSize == -1 { |
| 29 | dst.Result = nil |
| 30 | return nil |
| 31 | } |
| 32 | |
| 33 | if resultSize < 0 || len(src[rp:]) != resultSize { |
| 34 | return &invalidMessageFormatErr{messageType: "FunctionCallResponse"} |
| 35 | } |
| 36 | |
| 37 | dst.Result = src[rp:] |
| 38 | return nil |
| 39 | } |
| 40 | |
| 41 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length. |
| 42 | func (src *FunctionCallResponse) Encode(dst []byte) ([]byte, error) { |