package pgproto3

import (
	
	

	
)

type BackendKeyData struct {
	ProcessID uint32
	SecretKey uint32
}

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

// 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 ( *BackendKeyData) ( []byte) error {
	if len() != 8 {
		return &invalidMessageLenErr{messageType: "BackendKeyData", expectedLen: 8, actualLen: len()}
	}

	.ProcessID = binary.BigEndian.Uint32([:4])
	.SecretKey = binary.BigEndian.Uint32([4:])

	return nil
}

// Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
func ( *BackendKeyData) ( []byte) []byte {
	 = append(, 'K')
	 = pgio.AppendUint32(, 12)
	 = pgio.AppendUint32(, .ProcessID)
	 = pgio.AppendUint32(, .SecretKey)
	return 
}

// MarshalJSON implements encoding/json.Marshaler.
func ( BackendKeyData) () ([]byte, error) {
	return json.Marshal(struct {
		      string
		 uint32
		 uint32
	}{
		:      "BackendKeyData",
		: .ProcessID,
		: .SecretKey,
	})
}