package pgproto3

import (
	
	
	

	
)

type NotificationResponse struct {
	PID     uint32
	Channel string
	Payload string
}

// Backend identifies this message as sendable by the PostgreSQL backend.
func (*NotificationResponse) () {}

// Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
// type identifier and 4 byte message length.
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
}

// Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
func ( *NotificationResponse) ( []byte) []byte {
	 = append(, 'A')
	 := len()
	 = pgio.AppendInt32(, -1)

	 = pgio.AppendUint32(, .PID)
	 = append(, .Channel...)
	 = append(, 0)
	 = append(, .Payload...)
	 = append(, 0)

	pgio.SetInt32([:], int32(len([:])))

	return 
}

// MarshalJSON implements encoding/json.Marshaler.
func ( NotificationResponse) () ([]byte, error) {
	return json.Marshal(struct {
		    string
		     uint32
		 string
		 string
	}{
		:    "NotificationResponse",
		:     .PID,
		: .Channel,
		: .Payload,
	})
}