package pgx
import (
)
const (
TextFormatCode = 0
BinaryFormatCode = 1
)
func ( *pgtype.Map, any) (any, error) {
, := .Encode(0, TextFormatCode, , []byte{})
if != nil {
return nil,
}
if == nil {
return nil, nil
}
return string(), nil
}
func ( *pgtype.Map, []byte, uint32, any) ([]byte, error) {
:= len()
= pgio.AppendInt32(, -1)
, := .Encode(, BinaryFormatCode, , )
if != nil {
if , := tryScanStringCopyValueThenEncode(, , , ); == nil {
=
} else {
return nil,
}
}
if != nil {
=
pgio.SetInt32([:], int32(len([:])-4))
}
return , nil
}
func ( *pgtype.Map, []byte, uint32, any) ([]byte, error) {
, := .(string)
if ! {
, := .Encode(, TextFormatCode, , nil)
if != nil {
return nil, errors.New("not a string and cannot be encoded as text")
}
= string()
}
var any
:= .Scan(, TextFormatCode, []byte(), &)
if != nil {
return nil,
}
return .Encode(, BinaryFormatCode, , )
}