package pgproto3
import (
)
type NotificationResponse struct {
PID uint32
Channel string
Payload string
}
func (*NotificationResponse) () {}
func ( *NotificationResponse) ( []byte) error {
:= bytes.NewBuffer()
if .Len() < 4 {
return &invalidMessageFormatErr{messageType: "NotificationResponse", details: "too short"}
}
:= binary.BigEndian.Uint32(.Next(4))
, := .ReadBytes(0)
if != nil {
return
}
:= string([:len()-1])
, = .ReadBytes(0)
if != nil {
return
}
:= string([:len()-1])
* = NotificationResponse{PID: , Channel: , Payload: }
return nil
}
func ( *NotificationResponse) ( []byte) ([]byte, error) {
, := beginMessage(, 'A')
= pgio.AppendUint32(, .PID)
= append(, .Channel...)
= append(, 0)
= append(, .Payload...)
= append(, 0)
return finishMessage(, )
}
func ( NotificationResponse) () ([]byte, error) {
return json.Marshal(struct {
string
uint32
string
string
}{
: "NotificationResponse",
: .PID,
: .Channel,
: .Payload,
})
}