-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathparse_complete.go
More file actions
56 lines (45 loc) · 1.03 KB
/
parse_complete.go
File metadata and controls
56 lines (45 loc) · 1.03 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package pgproto
import (
"bytes"
"fmt"
"io"
)
// '1' [int32 - length]
var rawParseCompleteMessage = [5]byte{
// Tag
'1',
// Length
'\x00', '\x00', '\x00', '\x04',
}
type ParseComplete struct{}
func (p *ParseComplete) server() {}
func ParseParseComplete(r io.Reader) (*ParseComplete, error) {
b := newReadBuffer(r)
var msg [5]byte
_, err := b.Read(msg[:])
if err != nil {
return nil, err
}
if !bytes.Equal(msg[:], rawParseCompleteMessage[:]) {
return nil, fmt.Errorf("invalid parse complete message")
}
return &ParseComplete{}, nil
}
func (p *ParseComplete) Encode() []byte {
// '1' [int32 - length]
return rawParseCompleteMessage[:]
}
// AsMap method returns a common map representation of this message:
//
// map[string]interface{}{
// "Type": "ParseComplete",
// "Payload": nil,
// },
// }
func (p *ParseComplete) AsMap() map[string]interface{} {
return map[string]interface{}{
"Type": "ParseComplete",
"Payload": nil,
}
}
func (p *ParseComplete) String() string { return messageToString(p) }