package pgproto3

import (
	
	

	
)

type PasswordMessage struct {
	Password string
}

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

// Frontend identifies this message as an authentication response.
func (*PasswordMessage) () {}

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

	,  := .ReadBytes(0)
	if  != nil {
		return 
	}
	.Password = string([:len()-1])

	return nil
}

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

	 = append(, .Password...)
	 = append(, 0)

	return 
}

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