gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

no_data.go (888B)


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