package pgproto3

import (
	
	

	
)

type Query struct {
	String string
}

// Frontend identifies this message as sendable by a PostgreSQL frontend.
func (*Query) () {}

// 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 ( *Query) ( []byte) error {
	 := bytes.IndexByte(, 0)
	if  != len()-1 {
		return &invalidMessageFormatErr{messageType: "Query"}
	}

	.String = string([:])

	return nil
}

// Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
func ( *Query) ( []byte) []byte {
	 = append(, 'Q')
	 = pgio.AppendInt32(, int32(4+len(.String)+1))

	 = append(, .String...)
	 = append(, 0)

	return 
}

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