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)
| 21 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message |
| 22 | // type identifier and 4 byte message length. |
| 23 | func (dst *CopyInResponse) Decode(src []byte) error { |
| 24 | buf := bytes.NewBuffer(src) |
| 25 | |
| 26 | if buf.Len() < 3 { |
| 27 | return &invalidMessageFormatErr{messageType: "CopyInResponse"} |
| 28 | } |
| 29 | |
| 30 | overallFormat := buf.Next(1)[0] |
| 31 | |
| 32 | columnCount := int(binary.BigEndian.Uint16(buf.Next(2))) |
| 33 | if buf.Len() != columnCount*2 { |
| 34 | return &invalidMessageFormatErr{messageType: "CopyInResponse"} |
| 35 | } |
| 36 | |
| 37 | columnFormatCodes := make([]uint16, columnCount) |
| 38 | for i := range columnCount { |
| 39 | columnFormatCodes[i] = binary.BigEndian.Uint16(buf.Next(2)) |
| 40 | } |
| 41 | |
| 42 | *dst = CopyInResponse{OverallFormat: overallFormat, ColumnFormatCodes: columnFormatCodes} |
| 43 | |
| 44 | return nil |
| 45 | } |
| 46 | |
| 47 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length. |
| 48 | func (src *CopyInResponse) Encode(dst []byte) ([]byte, error) { |