github.com/segmentio/kafka-go@v0.4.48-0.20240318174348-3f6244eb34fd/saslauthenticate.go (about)

     1  package kafka
     2  
     3  import (
     4  	"bufio"
     5  )
     6  
     7  type saslAuthenticateRequestV0 struct {
     8  	// Data holds the SASL payload
     9  	Data []byte
    10  }
    11  
    12  func (t saslAuthenticateRequestV0) size() int32 {
    13  	return sizeofBytes(t.Data)
    14  }
    15  
    16  func (t *saslAuthenticateRequestV0) readFrom(r *bufio.Reader, sz int) (remain int, err error) {
    17  	return readBytes(r, sz, &t.Data)
    18  }
    19  
    20  func (t saslAuthenticateRequestV0) writeTo(wb *writeBuffer) {
    21  	wb.writeBytes(t.Data)
    22  }
    23  
    24  type saslAuthenticateResponseV0 struct {
    25  	// ErrorCode holds response error code
    26  	ErrorCode int16
    27  
    28  	ErrorMessage string
    29  
    30  	Data []byte
    31  }
    32  
    33  func (t saslAuthenticateResponseV0) size() int32 {
    34  	return sizeofInt16(t.ErrorCode) + sizeofString(t.ErrorMessage) + sizeofBytes(t.Data)
    35  }
    36  
    37  func (t saslAuthenticateResponseV0) writeTo(wb *writeBuffer) {
    38  	wb.writeInt16(t.ErrorCode)
    39  	wb.writeString(t.ErrorMessage)
    40  	wb.writeBytes(t.Data)
    41  }
    42  
    43  func (t *saslAuthenticateResponseV0) readFrom(r *bufio.Reader, sz int) (remain int, err error) {
    44  	if remain, err = readInt16(r, sz, &t.ErrorCode); err != nil {
    45  		return
    46  	}
    47  	if remain, err = readString(r, remain, &t.ErrorMessage); err != nil {
    48  		return
    49  	}
    50  	if remain, err = readBytes(r, remain, &t.Data); err != nil {
    51  		return
    52  	}
    53  	return
    54  }