close_complete.go 951 B

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