package pgproto3

import (
	
	

	
)

type SASLResponse struct {
	Data []byte
}

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

// 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 ( *SASLResponse) ( []byte) error {
	* = SASLResponse{Data: }
	return nil
}

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

	 = append(, .Data...)

	return 
}

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

// UnmarshalJSON implements encoding/json.Unmarshaler.
func ( *SASLResponse) ( []byte) error {
	var  struct {
		 string
	}
	if  := json.Unmarshal(, &);  != nil {
		return 
	}
	if . != "" {
		,  := hex.DecodeString(.)
		if  != nil {
			return 
		}
		.Data = 
	}
	return nil
}