aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/jackc/pgx/pgproto3/no_data.go
blob: 1fb47c2a44f42ff4bda9536ff95ffec5f6e01c84 (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 NoData struct{}

func (*NoData) Backend() {}

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

	return nil
}

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

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