package pgtype

import 
CompositeFields scans the fields of a composite type into the elements of the CompositeFields value. To scan a nullable value use a *CompositeFields. It will be set to nil in case of null. CompositeFields implements EncodeBinary and EncodeText. However, functionality is limited due to CompositeFields not knowing the PostgreSQL schema of the composite type. Prefer using a registered CompositeType.
type CompositeFields []interface{}

func ( CompositeFields) ( *ConnInfo,  []byte) error {
	if len() == 0 {
		return fmt.Errorf("cannot decode into empty CompositeFields")
	}

	if  == nil {
		return fmt.Errorf("cannot decode unexpected null into CompositeFields")
	}

	 := NewCompositeBinaryScanner(, )

	for ,  := range  {
		.ScanValue()
	}

	if .Err() != nil {
		return .Err()
	}

	return nil
}

func ( CompositeFields) ( *ConnInfo,  []byte) error {
	if len() == 0 {
		return fmt.Errorf("cannot decode into empty CompositeFields")
	}

	if  == nil {
		return fmt.Errorf("cannot decode unexpected null into CompositeFields")
	}

	 := NewCompositeTextScanner(, )

	for ,  := range  {
		.ScanValue()
	}

	if .Err() != nil {
		return .Err()
	}

	return nil
}
EncodeText encodes composite fields into the text format. Prefer registering a CompositeType to using CompositeFields to encode directly.
func ( CompositeFields) ( *ConnInfo,  []byte) ([]byte, error) {
	 := NewCompositeTextBuilder(, )

	for ,  := range  {
		if ,  := .(TextEncoder);  {
			.AppendEncoder()
		} else {
			.AppendValue()
		}
	}

	return .Finish()
}
EncodeBinary encodes composite fields into the binary format. Unlike CompositeType the schema of the destination is unknown. Prefer registering a CompositeType to using CompositeFields to encode directly. Because the binary composite format requires the OID of each field to be specified the only types that will work are those known to ConnInfo. In particular: * Nil cannot be used because there is no way to determine what type it. * Integer types must be exact matches. e.g. A Go int32 into a PostgreSQL bigint will fail. * No dereferencing will be done. e.g. *Text must be used instead of Text.
func ( CompositeFields) ( *ConnInfo,  []byte) ([]byte, error) {
	 := NewCompositeBinaryBuilder(, )

	for ,  := range  {
		,  := .DataTypeForValue()
		if ! {
			return nil, fmt.Errorf("Unknown OID for %#v", )
		}

		if ,  := .(BinaryEncoder);  {
			.AppendEncoder(.OID, )
		} else {
			 := .Value.Set()
			if  != nil {
				return nil, 
			}
			if ,  := .Value.(BinaryEncoder);  {
				.AppendEncoder(.OID, )
			} else {
				return nil, fmt.Errorf("Cannot encode binary format for %v", )
			}
		}
	}

	return .Finish()