github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/archive/codecs/ReplayRequest.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 ReplayRequest struct {
    13  	ControlSessionId int64
    14  	CorrelationId    int64
    15  	RecordingId      int64
    16  	Position         int64
    17  	Length           int64
    18  	ReplayStreamId   int32
    19  	ReplayChannel    []uint8
    20  }
    21  
    22  func (r *ReplayRequest) Encode(_m *SbeGoMarshaller, _w io.Writer, doRangeCheck bool) error {
    23  	if doRangeCheck {
    24  		if err := r.RangeCheck(r.SbeSchemaVersion(), r.SbeSchemaVersion()); err != nil {
    25  			return err
    26  		}
    27  	}
    28  	if err := _m.WriteInt64(_w, r.ControlSessionId); err != nil {
    29  		return err
    30  	}
    31  	if err := _m.WriteInt64(_w, r.CorrelationId); err != nil {
    32  		return err
    33  	}
    34  	if err := _m.WriteInt64(_w, r.RecordingId); err != nil {
    35  		return err
    36  	}
    37  	if err := _m.WriteInt64(_w, r.Position); err != nil {
    38  		return err
    39  	}
    40  	if err := _m.WriteInt64(_w, r.Length); err != nil {
    41  		return err
    42  	}
    43  	if err := _m.WriteInt32(_w, r.ReplayStreamId); err != nil {
    44  		return err
    45  	}
    46  	if err := _m.WriteUint32(_w, uint32(len(r.ReplayChannel))); err != nil {
    47  		return err
    48  	}
    49  	if err := _m.WriteBytes(_w, r.ReplayChannel); err != nil {
    50  		return err
    51  	}
    52  	return nil
    53  }
    54  
    55  func (r *ReplayRequest) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint16, doRangeCheck bool) error {
    56  	if !r.ControlSessionIdInActingVersion(actingVersion) {
    57  		r.ControlSessionId = r.ControlSessionIdNullValue()
    58  	} else {
    59  		if err := _m.ReadInt64(_r, &r.ControlSessionId); err != nil {
    60  			return err
    61  		}
    62  	}
    63  	if !r.CorrelationIdInActingVersion(actingVersion) {
    64  		r.CorrelationId = r.CorrelationIdNullValue()
    65  	} else {
    66  		if err := _m.ReadInt64(_r, &r.CorrelationId); err != nil {
    67  			return err
    68  		}
    69  	}
    70  	if !r.RecordingIdInActingVersion(actingVersion) {
    71  		r.RecordingId = r.RecordingIdNullValue()
    72  	} else {
    73  		if err := _m.ReadInt64(_r, &r.RecordingId); err != nil {
    74  			return err
    75  		}
    76  	}
    77  	if !r.PositionInActingVersion(actingVersion) {
    78  		r.Position = r.PositionNullValue()
    79  	} else {
    80  		if err := _m.ReadInt64(_r, &r.Position); err != nil {
    81  			return err
    82  		}
    83  	}
    84  	if !r.LengthInActingVersion(actingVersion) {
    85  		r.Length = r.LengthNullValue()
    86  	} else {
    87  		if err := _m.ReadInt64(_r, &r.Length); err != nil {
    88  			return err
    89  		}
    90  	}
    91  	if !r.ReplayStreamIdInActingVersion(actingVersion) {
    92  		r.ReplayStreamId = r.ReplayStreamIdNullValue()
    93  	} else {
    94  		if err := _m.ReadInt32(_r, &r.ReplayStreamId); err != nil {
    95  			return err
    96  		}
    97  	}
    98  	if actingVersion > r.SbeSchemaVersion() && blockLength > r.SbeBlockLength() {
    99  		io.CopyN(ioutil.Discard, _r, int64(blockLength-r.SbeBlockLength()))
   100  	}
   101  
   102  	if r.ReplayChannelInActingVersion(actingVersion) {
   103  		var ReplayChannelLength uint32
   104  		if err := _m.ReadUint32(_r, &ReplayChannelLength); err != nil {
   105  			return err
   106  		}
   107  		if cap(r.ReplayChannel) < int(ReplayChannelLength) {
   108  			r.ReplayChannel = make([]uint8, ReplayChannelLength)
   109  		}
   110  		r.ReplayChannel = r.ReplayChannel[:ReplayChannelLength]
   111  		if err := _m.ReadBytes(_r, r.ReplayChannel); err != nil {
   112  			return err
   113  		}
   114  	}
   115  	if doRangeCheck {
   116  		if err := r.RangeCheck(actingVersion, r.SbeSchemaVersion()); err != nil {
   117  			return err
   118  		}
   119  	}
   120  	return nil
   121  }
   122  
   123  func (r *ReplayRequest) RangeCheck(actingVersion uint16, schemaVersion uint16) error {
   124  	if r.ControlSessionIdInActingVersion(actingVersion) {
   125  		if r.ControlSessionId < r.ControlSessionIdMinValue() || r.ControlSessionId > r.ControlSessionIdMaxValue() {
   126  			return fmt.Errorf("Range check failed on r.ControlSessionId (%v < %v > %v)", r.ControlSessionIdMinValue(), r.ControlSessionId, r.ControlSessionIdMaxValue())
   127  		}
   128  	}
   129  	if r.CorrelationIdInActingVersion(actingVersion) {
   130  		if r.CorrelationId < r.CorrelationIdMinValue() || r.CorrelationId > r.CorrelationIdMaxValue() {
   131  			return fmt.Errorf("Range check failed on r.CorrelationId (%v < %v > %v)", r.CorrelationIdMinValue(), r.CorrelationId, r.CorrelationIdMaxValue())
   132  		}
   133  	}
   134  	if r.RecordingIdInActingVersion(actingVersion) {
   135  		if r.RecordingId < r.RecordingIdMinValue() || r.RecordingId > r.RecordingIdMaxValue() {
   136  			return fmt.Errorf("Range check failed on r.RecordingId (%v < %v > %v)", r.RecordingIdMinValue(), r.RecordingId, r.RecordingIdMaxValue())
   137  		}
   138  	}
   139  	if r.PositionInActingVersion(actingVersion) {
   140  		if r.Position < r.PositionMinValue() || r.Position > r.PositionMaxValue() {
   141  			return fmt.Errorf("Range check failed on r.Position (%v < %v > %v)", r.PositionMinValue(), r.Position, r.PositionMaxValue())
   142  		}
   143  	}
   144  	if r.LengthInActingVersion(actingVersion) {
   145  		if r.Length < r.LengthMinValue() || r.Length > r.LengthMaxValue() {
   146  			return fmt.Errorf("Range check failed on r.Length (%v < %v > %v)", r.LengthMinValue(), r.Length, r.LengthMaxValue())
   147  		}
   148  	}
   149  	if r.ReplayStreamIdInActingVersion(actingVersion) {
   150  		if r.ReplayStreamId < r.ReplayStreamIdMinValue() || r.ReplayStreamId > r.ReplayStreamIdMaxValue() {
   151  			return fmt.Errorf("Range check failed on r.ReplayStreamId (%v < %v > %v)", r.ReplayStreamIdMinValue(), r.ReplayStreamId, r.ReplayStreamIdMaxValue())
   152  		}
   153  	}
   154  	return nil
   155  }
   156  
   157  func ReplayRequestInit(r *ReplayRequest) {
   158  	return
   159  }
   160  
   161  func (*ReplayRequest) SbeBlockLength() (blockLength uint16) {
   162  	return 44
   163  }
   164  
   165  func (*ReplayRequest) SbeTemplateId() (templateId uint16) {
   166  	return 6
   167  }
   168  
   169  func (*ReplayRequest) SbeSchemaId() (schemaId uint16) {
   170  	return 101
   171  }
   172  
   173  func (*ReplayRequest) SbeSchemaVersion() (schemaVersion uint16) {
   174  	return 6
   175  }
   176  
   177  func (*ReplayRequest) SbeSemanticType() (semanticType []byte) {
   178  	return []byte("")
   179  }
   180  
   181  func (*ReplayRequest) ControlSessionIdId() uint16 {
   182  	return 1
   183  }
   184  
   185  func (*ReplayRequest) ControlSessionIdSinceVersion() uint16 {
   186  	return 0
   187  }
   188  
   189  func (r *ReplayRequest) ControlSessionIdInActingVersion(actingVersion uint16) bool {
   190  	return actingVersion >= r.ControlSessionIdSinceVersion()
   191  }
   192  
   193  func (*ReplayRequest) ControlSessionIdDeprecated() uint16 {
   194  	return 0
   195  }
   196  
   197  func (*ReplayRequest) ControlSessionIdMetaAttribute(meta int) string {
   198  	switch meta {
   199  	case 1:
   200  		return ""
   201  	case 2:
   202  		return ""
   203  	case 3:
   204  		return ""
   205  	case 4:
   206  		return "required"
   207  	}
   208  	return ""
   209  }
   210  
   211  func (*ReplayRequest) ControlSessionIdMinValue() int64 {
   212  	return math.MinInt64 + 1
   213  }
   214  
   215  func (*ReplayRequest) ControlSessionIdMaxValue() int64 {
   216  	return math.MaxInt64
   217  }
   218  
   219  func (*ReplayRequest) ControlSessionIdNullValue() int64 {
   220  	return math.MinInt64
   221  }
   222  
   223  func (*ReplayRequest) CorrelationIdId() uint16 {
   224  	return 2
   225  }
   226  
   227  func (*ReplayRequest) CorrelationIdSinceVersion() uint16 {
   228  	return 0
   229  }
   230  
   231  func (r *ReplayRequest) CorrelationIdInActingVersion(actingVersion uint16) bool {
   232  	return actingVersion >= r.CorrelationIdSinceVersion()
   233  }
   234  
   235  func (*ReplayRequest) CorrelationIdDeprecated() uint16 {
   236  	return 0
   237  }
   238  
   239  func (*ReplayRequest) CorrelationIdMetaAttribute(meta int) string {
   240  	switch meta {
   241  	case 1:
   242  		return ""
   243  	case 2:
   244  		return ""
   245  	case 3:
   246  		return ""
   247  	case 4:
   248  		return "required"
   249  	}
   250  	return ""
   251  }
   252  
   253  func (*ReplayRequest) CorrelationIdMinValue() int64 {
   254  	return math.MinInt64 + 1
   255  }
   256  
   257  func (*ReplayRequest) CorrelationIdMaxValue() int64 {
   258  	return math.MaxInt64
   259  }
   260  
   261  func (*ReplayRequest) CorrelationIdNullValue() int64 {
   262  	return math.MinInt64
   263  }
   264  
   265  func (*ReplayRequest) RecordingIdId() uint16 {
   266  	return 3
   267  }
   268  
   269  func (*ReplayRequest) RecordingIdSinceVersion() uint16 {
   270  	return 0
   271  }
   272  
   273  func (r *ReplayRequest) RecordingIdInActingVersion(actingVersion uint16) bool {
   274  	return actingVersion >= r.RecordingIdSinceVersion()
   275  }
   276  
   277  func (*ReplayRequest) RecordingIdDeprecated() uint16 {
   278  	return 0
   279  }
   280  
   281  func (*ReplayRequest) RecordingIdMetaAttribute(meta int) string {
   282  	switch meta {
   283  	case 1:
   284  		return ""
   285  	case 2:
   286  		return ""
   287  	case 3:
   288  		return ""
   289  	case 4:
   290  		return "required"
   291  	}
   292  	return ""
   293  }
   294  
   295  func (*ReplayRequest) RecordingIdMinValue() int64 {
   296  	return math.MinInt64 + 1
   297  }
   298  
   299  func (*ReplayRequest) RecordingIdMaxValue() int64 {
   300  	return math.MaxInt64
   301  }
   302  
   303  func (*ReplayRequest) RecordingIdNullValue() int64 {
   304  	return math.MinInt64
   305  }
   306  
   307  func (*ReplayRequest) PositionId() uint16 {
   308  	return 4
   309  }
   310  
   311  func (*ReplayRequest) PositionSinceVersion() uint16 {
   312  	return 0
   313  }
   314  
   315  func (r *ReplayRequest) PositionInActingVersion(actingVersion uint16) bool {
   316  	return actingVersion >= r.PositionSinceVersion()
   317  }
   318  
   319  func (*ReplayRequest) PositionDeprecated() uint16 {
   320  	return 0
   321  }
   322  
   323  func (*ReplayRequest) PositionMetaAttribute(meta int) string {
   324  	switch meta {
   325  	case 1:
   326  		return ""
   327  	case 2:
   328  		return ""
   329  	case 3:
   330  		return ""
   331  	case 4:
   332  		return "required"
   333  	}
   334  	return ""
   335  }
   336  
   337  func (*ReplayRequest) PositionMinValue() int64 {
   338  	return math.MinInt64 + 1
   339  }
   340  
   341  func (*ReplayRequest) PositionMaxValue() int64 {
   342  	return math.MaxInt64
   343  }
   344  
   345  func (*ReplayRequest) PositionNullValue() int64 {
   346  	return math.MinInt64
   347  }
   348  
   349  func (*ReplayRequest) LengthId() uint16 {
   350  	return 5
   351  }
   352  
   353  func (*ReplayRequest) LengthSinceVersion() uint16 {
   354  	return 0
   355  }
   356  
   357  func (r *ReplayRequest) LengthInActingVersion(actingVersion uint16) bool {
   358  	return actingVersion >= r.LengthSinceVersion()
   359  }
   360  
   361  func (*ReplayRequest) LengthDeprecated() uint16 {
   362  	return 0
   363  }
   364  
   365  func (*ReplayRequest) LengthMetaAttribute(meta int) string {
   366  	switch meta {
   367  	case 1:
   368  		return ""
   369  	case 2:
   370  		return ""
   371  	case 3:
   372  		return ""
   373  	case 4:
   374  		return "required"
   375  	}
   376  	return ""
   377  }
   378  
   379  func (*ReplayRequest) LengthMinValue() int64 {
   380  	return math.MinInt64 + 1
   381  }
   382  
   383  func (*ReplayRequest) LengthMaxValue() int64 {
   384  	return math.MaxInt64
   385  }
   386  
   387  func (*ReplayRequest) LengthNullValue() int64 {
   388  	return math.MinInt64
   389  }
   390  
   391  func (*ReplayRequest) ReplayStreamIdId() uint16 {
   392  	return 6
   393  }
   394  
   395  func (*ReplayRequest) ReplayStreamIdSinceVersion() uint16 {
   396  	return 0
   397  }
   398  
   399  func (r *ReplayRequest) ReplayStreamIdInActingVersion(actingVersion uint16) bool {
   400  	return actingVersion >= r.ReplayStreamIdSinceVersion()
   401  }
   402  
   403  func (*ReplayRequest) ReplayStreamIdDeprecated() uint16 {
   404  	return 0
   405  }
   406  
   407  func (*ReplayRequest) ReplayStreamIdMetaAttribute(meta int) string {
   408  	switch meta {
   409  	case 1:
   410  		return ""
   411  	case 2:
   412  		return ""
   413  	case 3:
   414  		return ""
   415  	case 4:
   416  		return "required"
   417  	}
   418  	return ""
   419  }
   420  
   421  func (*ReplayRequest) ReplayStreamIdMinValue() int32 {
   422  	return math.MinInt32 + 1
   423  }
   424  
   425  func (*ReplayRequest) ReplayStreamIdMaxValue() int32 {
   426  	return math.MaxInt32
   427  }
   428  
   429  func (*ReplayRequest) ReplayStreamIdNullValue() int32 {
   430  	return math.MinInt32
   431  }
   432  
   433  func (*ReplayRequest) ReplayChannelMetaAttribute(meta int) string {
   434  	switch meta {
   435  	case 1:
   436  		return ""
   437  	case 2:
   438  		return ""
   439  	case 3:
   440  		return ""
   441  	case 4:
   442  		return "required"
   443  	}
   444  	return ""
   445  }
   446  
   447  func (*ReplayRequest) ReplayChannelSinceVersion() uint16 {
   448  	return 0
   449  }
   450  
   451  func (r *ReplayRequest) ReplayChannelInActingVersion(actingVersion uint16) bool {
   452  	return actingVersion >= r.ReplayChannelSinceVersion()
   453  }
   454  
   455  func (*ReplayRequest) ReplayChannelDeprecated() uint16 {
   456  	return 0
   457  }
   458  
   459  func (ReplayRequest) ReplayChannelCharacterEncoding() string {
   460  	return "US-ASCII"
   461  }
   462  
   463  func (ReplayRequest) ReplayChannelHeaderLength() uint64 {
   464  	return 4
   465  }