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

Method Encode

pgproto3/cancel_request.go:43–53  ·  view source on GitHub ↗

Encode encodes src into dst. dst will include the 4 byte message length.

(dst []byte)

Source from the content-addressed store, hash-verified

41
42// Encode encodes src into dst. dst will include the 4 byte message length.
43func (src *CancelRequest) Encode(dst []byte) ([]byte, error) {
44 if len(src.SecretKey) > 256 {
45 return nil, errors.New("secret key too long")
46 }
47 msgLen := int32(12 + len(src.SecretKey))
48 dst = pgio.AppendInt32(dst, msgLen)
49 dst = pgio.AppendInt32(dst, cancelRequestCode)
50 dst = pgio.AppendUint32(dst, src.ProcessID)
51 dst = append(dst, src.SecretKey...)
52 return dst, nil
53}
54
55// MarshalJSON implements encoding/json.Marshaler.
56func (src CancelRequest) MarshalJSON() ([]byte, error) {

Callers

nothing calls this directly

Calls 2

AppendInt32Function · 0.92
AppendUint32Function · 0.92

Tested by

no test coverage detected