package pgproto3

import (
	
	

	
)

type CopyData struct {
	Data []byte
}

// Backend identifies this message as sendable by the PostgreSQL backend.
func (*CopyData) () {}

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

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

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

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

// UnmarshalJSON implements encoding/json.Unmarshaler.
func ( *CopyData) ( []byte) error {
	// Ignore null, like in the main JSON package.
	if string() == "null" {
		return nil
	}

	var  struct {
		 string
	}
	if  := json.Unmarshal(, &);  != nil {
		return 
	}

	.Data = []byte(.)
	return nil
}