Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
(dst []byte)
| 101 | |
| 102 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length. |
| 103 | func (src *RowDescription) Encode(dst []byte) ([]byte, error) { |
| 104 | dst, sp := beginMessage(dst, 'T') |
| 105 | |
| 106 | if len(src.Fields) > math.MaxUint16 { |
| 107 | return nil, errors.New("too many fields") |
| 108 | } |
| 109 | dst = pgio.AppendUint16(dst, uint16(len(src.Fields))) |
| 110 | for _, fd := range src.Fields { |
| 111 | dst = append(dst, fd.Name...) |
| 112 | dst = append(dst, 0) |
| 113 | |
| 114 | dst = pgio.AppendUint32(dst, fd.TableOID) |
| 115 | dst = pgio.AppendUint16(dst, fd.TableAttributeNumber) |
| 116 | dst = pgio.AppendUint32(dst, fd.DataTypeOID) |
| 117 | dst = pgio.AppendInt16(dst, fd.DataTypeSize) |
| 118 | dst = pgio.AppendInt32(dst, fd.TypeModifier) |
| 119 | dst = pgio.AppendInt16(dst, fd.Format) |
| 120 | } |
| 121 | |
| 122 | return finishMessage(dst, sp) |
| 123 | } |
| 124 | |
| 125 | // MarshalJSON implements encoding/json.Marshaler. |
| 126 | func (src RowDescription) MarshalJSON() ([]byte, error) { |
nothing calls this directly
no test coverage detected