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

Method Decode

pgproto3/function_call_response.go:20–39  ·  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

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.
20func (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.
42func (src *FunctionCallResponse) Encode(dst []byte) ([]byte, error) {

Calls 1

Uint32Method · 0.80