MCPcopy
hub / github.com/jackc/pgx / Decode

Method Decode

pgproto3/copy_both_response.go:23–45  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
23func (dst *CopyBothResponse) Decode(src []byte) error {
24 buf := bytes.NewBuffer(src)
25
26 if buf.Len() < 3 {
27 return &invalidMessageFormatErr{messageType: "CopyBothResponse"}
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: "CopyBothResponse"}
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 = CopyBothResponse{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.
48func (src *CopyBothResponse) Encode(dst []byte) ([]byte, error) {

Callers 2

FuzzCopyBothResponseFunction · 0.95
TestEncodeDecodeFunction · 0.95

Calls 3

Uint16Method · 0.80
LenMethod · 0.65
NextMethod · 0.65

Tested by 2

FuzzCopyBothResponseFunction · 0.76
TestEncodeDecodeFunction · 0.76