package pgproto3

import (
	
	
)

type ReadyForQuery struct {
	TxStatus byte
}

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

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

	.TxStatus = [0]

	return nil
}

// Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
func ( *ReadyForQuery) ( []byte) []byte {
	return append(, 'Z', 0, 0, 0, 5, .TxStatus)
}

// MarshalJSON implements encoding/json.Marshaler.
func ( ReadyForQuery) () ([]byte, error) {
	return json.Marshal(struct {
		     string
		 string
	}{
		:     "ReadyForQuery",
		: string(.TxStatus),
	})
}

// UnmarshalJSON implements encoding/json.Unmarshaler.
func ( *ReadyForQuery) ( []byte) error {
	// Ignore null, like in the main JSON package.
	if string() == "null" {
		return nil
	}

	var  struct {
		 string
	}
	if  := json.Unmarshal(, &);  != nil {
		return 
	}
	if len(.) != 1 {
		return errors.New("invalid length for ReadyForQuery.TxStatus")
	}
	.TxStatus = .[0]
	return nil
}