package pgproto3

import (
	
	
	
	
	

	
)

type ParameterDescription struct {
	ParameterOIDs []uint32
}

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

// 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 ( *ParameterDescription) ( []byte) error {
	 := bytes.NewBuffer()

	if .Len() < 2 {
		return &invalidMessageFormatErr{messageType: "ParameterDescription"}
	}

	// Reported parameter count will be incorrect when number of args is greater than uint16
	.Next(2)
	// Instead infer parameter count by remaining size of message
	 := .Len() / 4

	* = ParameterDescription{ParameterOIDs: make([]uint32, )}

	for  := range  {
		.ParameterOIDs[] = binary.BigEndian.Uint32(.Next(4))
	}

	return nil
}

// Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
func ( *ParameterDescription) ( []byte) ([]byte, error) {
	,  := beginMessage(, 't')

	if len(.ParameterOIDs) > math.MaxUint16 {
		return nil, errors.New("too many parameter oids")
	}
	 = pgio.AppendUint16(, uint16(len(.ParameterOIDs)))
	for ,  := range .ParameterOIDs {
		 = pgio.AppendUint32(, )
	}

	return finishMessage(, )
}

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