aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/jackc/pgx/pgproto3/terminate.go
blob: 0a3310da7ee4b7de309ba0a3b05a0bc4ddbae1ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package pgproto3

import (
	"encoding/json"
)

type Terminate struct{}

func (*Terminate) Frontend() {}

func (dst *Terminate) Decode(src []byte) error {
	if len(src) != 0 {
		return &invalidMessageLenErr{messageType: "Terminate", expectedLen: 0, actualLen: len(src)}
	}

	return nil
}

func (src *Terminate) Encode(dst []byte) []byte {
	return append(dst, 'X', 0, 0, 0, 4)
}

func (src *Terminate) MarshalJSON() ([]byte, error) {
	return json.Marshal(struct {
		Type string
	}{
		Type: "Terminate",
	})
}