copy_done.go (1010B)
1 package pgproto3 2 3 import ( 4 "encoding/json" 5 ) 6 7 type CopyDone struct { 8 } 9 10 // Backend identifies this message as sendable by the PostgreSQL backend. 11 func (*CopyDone) Backend() {} 12 13 // Frontend identifies this message as sendable by a PostgreSQL frontend. 14 func (*CopyDone) Frontend() {} 15 16 // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message 17 // type identifier and 4 byte message length. 18 func (dst *CopyDone) Decode(src []byte) error { 19 if len(src) != 0 { 20 return &invalidMessageLenErr{messageType: "CopyDone", expectedLen: 0, actualLen: len(src)} 21 } 22 23 return nil 24 } 25 26 // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length. 27 func (src *CopyDone) Encode(dst []byte) []byte { 28 return append(dst, 'c', 0, 0, 0, 4) 29 } 30 31 // MarshalJSON implements encoding/json.Marshaler. 32 func (src CopyDone) MarshalJSON() ([]byte, error) { 33 return json.Marshal(struct { 34 Type string 35 }{ 36 Type: "CopyDone", 37 }) 38 }