package pgproto3

import (
	
	
	

	
)
AuthenticationSASL is a message sent from the backend indicating that SASL authentication is required.
Backend identifies this message as sendable by the PostgreSQL backend.
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 ( *AuthenticationSASL) ( []byte) error {
	if len() < 4 {
		return errors.New("authentication message too short")
	}

	 := binary.BigEndian.Uint32()

	if  != AuthTypeSASL {
		return errors.New("bad auth type")
	}

	 := [4:]
	for len() > 1 {
		 := bytes.IndexByte(, 0)
		if  > 0 {
			.AuthMechanisms = append(.AuthMechanisms, string([:]))
			 = [+1:]
		}
	}

	return nil
}
Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
func ( *AuthenticationSASL) ( []byte) []byte {
	 = append(, 'R')
	 := len()
	 = pgio.AppendInt32(, -1)
	 = pgio.AppendUint32(, AuthTypeSASL)

	for ,  := range .AuthMechanisms {
		 = append(, []byte()...)
		 = append(, 0)
	}
	 = append(, 0)

	pgio.SetInt32([:], int32(len([:])))

	return