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

Method Decode

pgproto3/notification_response.go:22–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

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 *NotificationResponse) Decode(src []byte) error {
23 buf := bytes.NewBuffer(src)
24
25 if buf.Len() < 4 {
26 return &invalidMessageFormatErr{messageType: "NotificationResponse", details: "too short"}
27 }
28
29 pid := binary.BigEndian.Uint32(buf.Next(4))
30
31 b, err := buf.ReadBytes(0)
32 if err != nil {
33 return err
34 }
35 channel := string(b[:len(b)-1])
36
37 b, err = buf.ReadBytes(0)
38 if err != nil {
39 return err
40 }
41 payload := string(b[:len(b)-1])
42
43 *dst = NotificationResponse{PID: pid, Channel: channel, Payload: payload}
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 *NotificationResponse) Encode(dst []byte) ([]byte, error) {

Callers 1

FuzzNotificationResponseFunction · 0.95

Calls 3

Uint32Method · 0.80
LenMethod · 0.65
NextMethod · 0.65

Tested by 1

FuzzNotificationResponseFunction · 0.76