github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/archive/codecs/ChallengeResponse.go (about)

     1  // Generated SBE (Simple Binary Encoding) message codec
     2  
     3  package codecs
     4  
     5  import (
     6  	"fmt"
     7  	"io"
     8  	"io/ioutil"
     9  	"math"
    10  )
    11  
    12  type ChallengeResponse struct {
    13  	ControlSessionId   int64
    14  	CorrelationId      int64
    15  	EncodedCredentials []uint8
    16  }
    17  
    18  func (c *ChallengeResponse) Encode(_m *SbeGoMarshaller, _w io.Writer, doRangeCheck bool) error {
    19  	if doRangeCheck {
    20  		if err := c.RangeCheck(c.SbeSchemaVersion(), c.SbeSchemaVersion()); err != nil {
    21  			return err
    22  		}
    23  	}
    24  	if err := _m.WriteInt64(_w, c.ControlSessionId); err != nil {
    25  		return err
    26  	}
    27  	if err := _m.WriteInt64(_w, c.CorrelationId); err != nil {
    28  		return err
    29  	}
    30  	if err := _m.WriteUint32(_w, uint32(len(c.EncodedCredentials))); err != nil {
    31  		return err
    32  	}
    33  	if err := _m.WriteBytes(_w, c.EncodedCredentials); err != nil {
    34  		return err
    35  	}
    36  	return nil
    37  }
    38  
    39  func (c *ChallengeResponse) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint16, doRangeCheck bool) error {
    40  	if !c.ControlSessionIdInActingVersion(actingVersion) {
    41  		c.ControlSessionId = c.ControlSessionIdNullValue()
    42  	} else {
    43  		if err := _m.ReadInt64(_r, &c.ControlSessionId); err != nil {
    44  			return err
    45  		}
    46  	}
    47  	if !c.CorrelationIdInActingVersion(actingVersion) {
    48  		c.CorrelationId = c.CorrelationIdNullValue()
    49  	} else {
    50  		if err := _m.ReadInt64(_r, &c.CorrelationId); err != nil {
    51  			return err
    52  		}
    53  	}
    54  	if actingVersion > c.SbeSchemaVersion() && blockLength > c.SbeBlockLength() {
    55  		io.CopyN(ioutil.Discard, _r, int64(blockLength-c.SbeBlockLength()))
    56  	}
    57  
    58  	if c.EncodedCredentialsInActingVersion(actingVersion) {
    59  		var EncodedCredentialsLength uint32
    60  		if err := _m.ReadUint32(_r, &EncodedCredentialsLength); err != nil {
    61  			return err
    62  		}
    63  		if cap(c.EncodedCredentials) < int(EncodedCredentialsLength) {
    64  			c.EncodedCredentials = make([]uint8, EncodedCredentialsLength)
    65  		}
    66  		c.EncodedCredentials = c.EncodedCredentials[:EncodedCredentialsLength]
    67  		if err := _m.ReadBytes(_r, c.EncodedCredentials); err != nil {
    68  			return err
    69  		}
    70  	}
    71  	if doRangeCheck {
    72  		if err := c.RangeCheck(actingVersion, c.SbeSchemaVersion()); err != nil {
    73  			return err
    74  		}
    75  	}
    76  	return nil
    77  }
    78  
    79  func (c *ChallengeResponse) RangeCheck(actingVersion uint16, schemaVersion uint16) error {
    80  	if c.ControlSessionIdInActingVersion(actingVersion) {
    81  		if c.ControlSessionId < c.ControlSessionIdMinValue() || c.ControlSessionId > c.ControlSessionIdMaxValue() {
    82  			return fmt.Errorf("Range check failed on c.ControlSessionId (%v < %v > %v)", c.ControlSessionIdMinValue(), c.ControlSessionId, c.ControlSessionIdMaxValue())
    83  		}
    84  	}
    85  	if c.CorrelationIdInActingVersion(actingVersion) {
    86  		if c.CorrelationId < c.CorrelationIdMinValue() || c.CorrelationId > c.CorrelationIdMaxValue() {
    87  			return fmt.Errorf("Range check failed on c.CorrelationId (%v < %v > %v)", c.CorrelationIdMinValue(), c.CorrelationId, c.CorrelationIdMaxValue())
    88  		}
    89  	}
    90  	return nil
    91  }
    92  
    93  func ChallengeResponseInit(c *ChallengeResponse) {
    94  	return
    95  }
    96  
    97  func (*ChallengeResponse) SbeBlockLength() (blockLength uint16) {
    98  	return 16
    99  }
   100  
   101  func (*ChallengeResponse) SbeTemplateId() (templateId uint16) {
   102  	return 60
   103  }
   104  
   105  func (*ChallengeResponse) SbeSchemaId() (schemaId uint16) {
   106  	return 101
   107  }
   108  
   109  func (*ChallengeResponse) SbeSchemaVersion() (schemaVersion uint16) {
   110  	return 6
   111  }
   112  
   113  func (*ChallengeResponse) SbeSemanticType() (semanticType []byte) {
   114  	return []byte("")
   115  }
   116  
   117  func (*ChallengeResponse) ControlSessionIdId() uint16 {
   118  	return 1
   119  }
   120  
   121  func (*ChallengeResponse) ControlSessionIdSinceVersion() uint16 {
   122  	return 0
   123  }
   124  
   125  func (c *ChallengeResponse) ControlSessionIdInActingVersion(actingVersion uint16) bool {
   126  	return actingVersion >= c.ControlSessionIdSinceVersion()
   127  }
   128  
   129  func (*ChallengeResponse) ControlSessionIdDeprecated() uint16 {
   130  	return 0
   131  }
   132  
   133  func (*ChallengeResponse) ControlSessionIdMetaAttribute(meta int) string {
   134  	switch meta {
   135  	case 1:
   136  		return ""
   137  	case 2:
   138  		return ""
   139  	case 3:
   140  		return ""
   141  	case 4:
   142  		return "required"
   143  	}
   144  	return ""
   145  }
   146  
   147  func (*ChallengeResponse) ControlSessionIdMinValue() int64 {
   148  	return math.MinInt64 + 1
   149  }
   150  
   151  func (*ChallengeResponse) ControlSessionIdMaxValue() int64 {
   152  	return math.MaxInt64
   153  }
   154  
   155  func (*ChallengeResponse) ControlSessionIdNullValue() int64 {
   156  	return math.MinInt64
   157  }
   158  
   159  func (*ChallengeResponse) CorrelationIdId() uint16 {
   160  	return 2
   161  }
   162  
   163  func (*ChallengeResponse) CorrelationIdSinceVersion() uint16 {
   164  	return 0
   165  }
   166  
   167  func (c *ChallengeResponse) CorrelationIdInActingVersion(actingVersion uint16) bool {
   168  	return actingVersion >= c.CorrelationIdSinceVersion()
   169  }
   170  
   171  func (*ChallengeResponse) CorrelationIdDeprecated() uint16 {
   172  	return 0
   173  }
   174  
   175  func (*ChallengeResponse) CorrelationIdMetaAttribute(meta int) string {
   176  	switch meta {
   177  	case 1:
   178  		return ""
   179  	case 2:
   180  		return ""
   181  	case 3:
   182  		return ""
   183  	case 4:
   184  		return "required"
   185  	}
   186  	return ""
   187  }
   188  
   189  func (*ChallengeResponse) CorrelationIdMinValue() int64 {
   190  	return math.MinInt64 + 1
   191  }
   192  
   193  func (*ChallengeResponse) CorrelationIdMaxValue() int64 {
   194  	return math.MaxInt64
   195  }
   196  
   197  func (*ChallengeResponse) CorrelationIdNullValue() int64 {
   198  	return math.MinInt64
   199  }
   200  
   201  func (*ChallengeResponse) EncodedCredentialsMetaAttribute(meta int) string {
   202  	switch meta {
   203  	case 1:
   204  		return ""
   205  	case 2:
   206  		return ""
   207  	case 3:
   208  		return ""
   209  	case 4:
   210  		return "required"
   211  	}
   212  	return ""
   213  }
   214  
   215  func (*ChallengeResponse) EncodedCredentialsSinceVersion() uint16 {
   216  	return 0
   217  }
   218  
   219  func (c *ChallengeResponse) EncodedCredentialsInActingVersion(actingVersion uint16) bool {
   220  	return actingVersion >= c.EncodedCredentialsSinceVersion()
   221  }
   222  
   223  func (*ChallengeResponse) EncodedCredentialsDeprecated() uint16 {
   224  	return 0
   225  }
   226  
   227  func (ChallengeResponse) EncodedCredentialsCharacterEncoding() string {
   228  	return "null"
   229  }
   230  
   231  func (ChallengeResponse) EncodedCredentialsHeaderLength() uint64 {
   232  	return 4
   233  }