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

Method Decode

pgproto3/parameter_description.go:22–41  ·  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

20// Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
21// type identifier and 4 byte message length.
22func (dst *ParameterDescription) Decode(src []byte) error {
23 buf := bytes.NewBuffer(src)
24
25 if buf.Len() < 2 {
26 return &invalidMessageFormatErr{messageType: "ParameterDescription"}
27 }
28
29 // Reported parameter count will be incorrect when number of args is greater than uint16
30 buf.Next(2)
31 // Instead infer parameter count by remaining size of message
32 parameterCount := buf.Len() / 4
33
34 *dst = ParameterDescription{ParameterOIDs: make([]uint32, parameterCount)}
35
36 for i := range parameterCount {
37 dst.ParameterOIDs[i] = binary.BigEndian.Uint32(buf.Next(4))
38 }
39
40 return nil
41}
42
43// Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
44func (src *ParameterDescription) Encode(dst []byte) ([]byte, error) {

Callers 1

FuzzParameterDescriptionFunction · 0.95

Calls 3

Uint32Method · 0.80
LenMethod · 0.65
NextMethod · 0.65

Tested by 1

FuzzParameterDescriptionFunction · 0.76