github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/archive/codecs/RecordingStarted.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 RecordingStarted struct {
    13  	RecordingId    int64
    14  	StartPosition  int64
    15  	SessionId      int32
    16  	StreamId       int32
    17  	Channel        []uint8
    18  	SourceIdentity []uint8
    19  }
    20  
    21  func (r *RecordingStarted) Encode(_m *SbeGoMarshaller, _w io.Writer, doRangeCheck bool) error {
    22  	if doRangeCheck {
    23  		if err := r.RangeCheck(r.SbeSchemaVersion(), r.SbeSchemaVersion()); err != nil {
    24  			return err
    25  		}
    26  	}
    27  	if err := _m.WriteInt64(_w, r.RecordingId); err != nil {
    28  		return err
    29  	}
    30  	if err := _m.WriteInt64(_w, r.StartPosition); err != nil {
    31  		return err
    32  	}
    33  	if err := _m.WriteInt32(_w, r.SessionId); err != nil {
    34  		return err
    35  	}
    36  	if err := _m.WriteInt32(_w, r.StreamId); err != nil {
    37  		return err
    38  	}
    39  	if err := _m.WriteUint32(_w, uint32(len(r.Channel))); err != nil {
    40  		return err
    41  	}
    42  	if err := _m.WriteBytes(_w, r.Channel); err != nil {
    43  		return err
    44  	}
    45  	if err := _m.WriteUint32(_w, uint32(len(r.SourceIdentity))); err != nil {
    46  		return err
    47  	}
    48  	if err := _m.WriteBytes(_w, r.SourceIdentity); err != nil {
    49  		return err
    50  	}
    51  	return nil
    52  }
    53  
    54  func (r *RecordingStarted) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint16, doRangeCheck bool) error {
    55  	if !r.RecordingIdInActingVersion(actingVersion) {
    56  		r.RecordingId = r.RecordingIdNullValue()
    57  	} else {
    58  		if err := _m.ReadInt64(_r, &r.RecordingId); err != nil {
    59  			return err
    60  		}
    61  	}
    62  	if !r.StartPositionInActingVersion(actingVersion) {
    63  		r.StartPosition = r.StartPositionNullValue()
    64  	} else {
    65  		if err := _m.ReadInt64(_r, &r.StartPosition); err != nil {
    66  			return err
    67  		}
    68  	}
    69  	if !r.SessionIdInActingVersion(actingVersion) {
    70  		r.SessionId = r.SessionIdNullValue()
    71  	} else {
    72  		if err := _m.ReadInt32(_r, &r.SessionId); err != nil {
    73  			return err
    74  		}
    75  	}
    76  	if !r.StreamIdInActingVersion(actingVersion) {
    77  		r.StreamId = r.StreamIdNullValue()
    78  	} else {
    79  		if err := _m.ReadInt32(_r, &r.StreamId); err != nil {
    80  			return err
    81  		}
    82  	}
    83  	if actingVersion > r.SbeSchemaVersion() && blockLength > r.SbeBlockLength() {
    84  		io.CopyN(ioutil.Discard, _r, int64(blockLength-r.SbeBlockLength()))
    85  	}
    86  
    87  	if r.ChannelInActingVersion(actingVersion) {
    88  		var ChannelLength uint32
    89  		if err := _m.ReadUint32(_r, &ChannelLength); err != nil {
    90  			return err
    91  		}
    92  		if cap(r.Channel) < int(ChannelLength) {
    93  			r.Channel = make([]uint8, ChannelLength)
    94  		}
    95  		r.Channel = r.Channel[:ChannelLength]
    96  		if err := _m.ReadBytes(_r, r.Channel); err != nil {
    97  			return err
    98  		}
    99  	}
   100  
   101  	if r.SourceIdentityInActingVersion(actingVersion) {
   102  		var SourceIdentityLength uint32
   103  		if err := _m.ReadUint32(_r, &SourceIdentityLength); err != nil {
   104  			return err
   105  		}
   106  		if cap(r.SourceIdentity) < int(SourceIdentityLength) {
   107  			r.SourceIdentity = make([]uint8, SourceIdentityLength)
   108  		}
   109  		r.SourceIdentity = r.SourceIdentity[:SourceIdentityLength]
   110  		if err := _m.ReadBytes(_r, r.SourceIdentity); err != nil {
   111  			return err
   112  		}
   113  	}
   114  	if doRangeCheck {
   115  		if err := r.RangeCheck(actingVersion, r.SbeSchemaVersion()); err != nil {
   116  			return err
   117  		}
   118  	}
   119  	return nil
   120  }
   121  
   122  func (r *RecordingStarted) RangeCheck(actingVersion uint16, schemaVersion uint16) error {
   123  	if r.RecordingIdInActingVersion(actingVersion) {
   124  		if r.RecordingId < r.RecordingIdMinValue() || r.RecordingId > r.RecordingIdMaxValue() {
   125  			return fmt.Errorf("Range check failed on r.RecordingId (%v < %v > %v)", r.RecordingIdMinValue(), r.RecordingId, r.RecordingIdMaxValue())
   126  		}
   127  	}
   128  	if r.StartPositionInActingVersion(actingVersion) {
   129  		if r.StartPosition < r.StartPositionMinValue() || r.StartPosition > r.StartPositionMaxValue() {
   130  			return fmt.Errorf("Range check failed on r.StartPosition (%v < %v > %v)", r.StartPositionMinValue(), r.StartPosition, r.StartPositionMaxValue())
   131  		}
   132  	}
   133  	if r.SessionIdInActingVersion(actingVersion) {
   134  		if r.SessionId < r.SessionIdMinValue() || r.SessionId > r.SessionIdMaxValue() {
   135  			return fmt.Errorf("Range check failed on r.SessionId (%v < %v > %v)", r.SessionIdMinValue(), r.SessionId, r.SessionIdMaxValue())
   136  		}
   137  	}
   138  	if r.StreamIdInActingVersion(actingVersion) {
   139  		if r.StreamId < r.StreamIdMinValue() || r.StreamId > r.StreamIdMaxValue() {
   140  			return fmt.Errorf("Range check failed on r.StreamId (%v < %v > %v)", r.StreamIdMinValue(), r.StreamId, r.StreamIdMaxValue())
   141  		}
   142  	}
   143  	return nil
   144  }
   145  
   146  func RecordingStartedInit(r *RecordingStarted) {
   147  	return
   148  }
   149  
   150  func (*RecordingStarted) SbeBlockLength() (blockLength uint16) {
   151  	return 24
   152  }
   153  
   154  func (*RecordingStarted) SbeTemplateId() (templateId uint16) {
   155  	return 101
   156  }
   157  
   158  func (*RecordingStarted) SbeSchemaId() (schemaId uint16) {
   159  	return 101
   160  }
   161  
   162  func (*RecordingStarted) SbeSchemaVersion() (schemaVersion uint16) {
   163  	return 6
   164  }
   165  
   166  func (*RecordingStarted) SbeSemanticType() (semanticType []byte) {
   167  	return []byte("")
   168  }
   169  
   170  func (*RecordingStarted) RecordingIdId() uint16 {
   171  	return 1
   172  }
   173  
   174  func (*RecordingStarted) RecordingIdSinceVersion() uint16 {
   175  	return 0
   176  }
   177  
   178  func (r *RecordingStarted) RecordingIdInActingVersion(actingVersion uint16) bool {
   179  	return actingVersion >= r.RecordingIdSinceVersion()
   180  }
   181  
   182  func (*RecordingStarted) RecordingIdDeprecated() uint16 {
   183  	return 0
   184  }
   185  
   186  func (*RecordingStarted) RecordingIdMetaAttribute(meta int) string {
   187  	switch meta {
   188  	case 1:
   189  		return ""
   190  	case 2:
   191  		return ""
   192  	case 3:
   193  		return ""
   194  	case 4:
   195  		return "required"
   196  	}
   197  	return ""
   198  }
   199  
   200  func (*RecordingStarted) RecordingIdMinValue() int64 {
   201  	return math.MinInt64 + 1
   202  }
   203  
   204  func (*RecordingStarted) RecordingIdMaxValue() int64 {
   205  	return math.MaxInt64
   206  }
   207  
   208  func (*RecordingStarted) RecordingIdNullValue() int64 {
   209  	return math.MinInt64
   210  }
   211  
   212  func (*RecordingStarted) StartPositionId() uint16 {
   213  	return 2
   214  }
   215  
   216  func (*RecordingStarted) StartPositionSinceVersion() uint16 {
   217  	return 0
   218  }
   219  
   220  func (r *RecordingStarted) StartPositionInActingVersion(actingVersion uint16) bool {
   221  	return actingVersion >= r.StartPositionSinceVersion()
   222  }
   223  
   224  func (*RecordingStarted) StartPositionDeprecated() uint16 {
   225  	return 0
   226  }
   227  
   228  func (*RecordingStarted) StartPositionMetaAttribute(meta int) string {
   229  	switch meta {
   230  	case 1:
   231  		return ""
   232  	case 2:
   233  		return ""
   234  	case 3:
   235  		return ""
   236  	case 4:
   237  		return "required"
   238  	}
   239  	return ""
   240  }
   241  
   242  func (*RecordingStarted) StartPositionMinValue() int64 {
   243  	return math.MinInt64 + 1
   244  }
   245  
   246  func (*RecordingStarted) StartPositionMaxValue() int64 {
   247  	return math.MaxInt64
   248  }
   249  
   250  func (*RecordingStarted) StartPositionNullValue() int64 {
   251  	return math.MinInt64
   252  }
   253  
   254  func (*RecordingStarted) SessionIdId() uint16 {
   255  	return 3
   256  }
   257  
   258  func (*RecordingStarted) SessionIdSinceVersion() uint16 {
   259  	return 0
   260  }
   261  
   262  func (r *RecordingStarted) SessionIdInActingVersion(actingVersion uint16) bool {
   263  	return actingVersion >= r.SessionIdSinceVersion()
   264  }
   265  
   266  func (*RecordingStarted) SessionIdDeprecated() uint16 {
   267  	return 0
   268  }
   269  
   270  func (*RecordingStarted) SessionIdMetaAttribute(meta int) string {
   271  	switch meta {
   272  	case 1:
   273  		return ""
   274  	case 2:
   275  		return ""
   276  	case 3:
   277  		return ""
   278  	case 4:
   279  		return "required"
   280  	}
   281  	return ""
   282  }
   283  
   284  func (*RecordingStarted) SessionIdMinValue() int32 {
   285  	return math.MinInt32 + 1
   286  }
   287  
   288  func (*RecordingStarted) SessionIdMaxValue() int32 {
   289  	return math.MaxInt32
   290  }
   291  
   292  func (*RecordingStarted) SessionIdNullValue() int32 {
   293  	return math.MinInt32
   294  }
   295  
   296  func (*RecordingStarted) StreamIdId() uint16 {
   297  	return 4
   298  }
   299  
   300  func (*RecordingStarted) StreamIdSinceVersion() uint16 {
   301  	return 0
   302  }
   303  
   304  func (r *RecordingStarted) StreamIdInActingVersion(actingVersion uint16) bool {
   305  	return actingVersion >= r.StreamIdSinceVersion()
   306  }
   307  
   308  func (*RecordingStarted) StreamIdDeprecated() uint16 {
   309  	return 0
   310  }
   311  
   312  func (*RecordingStarted) StreamIdMetaAttribute(meta int) string {
   313  	switch meta {
   314  	case 1:
   315  		return ""
   316  	case 2:
   317  		return ""
   318  	case 3:
   319  		return ""
   320  	case 4:
   321  		return "required"
   322  	}
   323  	return ""
   324  }
   325  
   326  func (*RecordingStarted) StreamIdMinValue() int32 {
   327  	return math.MinInt32 + 1
   328  }
   329  
   330  func (*RecordingStarted) StreamIdMaxValue() int32 {
   331  	return math.MaxInt32
   332  }
   333  
   334  func (*RecordingStarted) StreamIdNullValue() int32 {
   335  	return math.MinInt32
   336  }
   337  
   338  func (*RecordingStarted) ChannelMetaAttribute(meta int) string {
   339  	switch meta {
   340  	case 1:
   341  		return ""
   342  	case 2:
   343  		return ""
   344  	case 3:
   345  		return ""
   346  	case 4:
   347  		return "required"
   348  	}
   349  	return ""
   350  }
   351  
   352  func (*RecordingStarted) ChannelSinceVersion() uint16 {
   353  	return 0
   354  }
   355  
   356  func (r *RecordingStarted) ChannelInActingVersion(actingVersion uint16) bool {
   357  	return actingVersion >= r.ChannelSinceVersion()
   358  }
   359  
   360  func (*RecordingStarted) ChannelDeprecated() uint16 {
   361  	return 0
   362  }
   363  
   364  func (RecordingStarted) ChannelCharacterEncoding() string {
   365  	return "US-ASCII"
   366  }
   367  
   368  func (RecordingStarted) ChannelHeaderLength() uint64 {
   369  	return 4
   370  }
   371  
   372  func (*RecordingStarted) SourceIdentityMetaAttribute(meta int) string {
   373  	switch meta {
   374  	case 1:
   375  		return ""
   376  	case 2:
   377  		return ""
   378  	case 3:
   379  		return ""
   380  	case 4:
   381  		return "required"
   382  	}
   383  	return ""
   384  }
   385  
   386  func (*RecordingStarted) SourceIdentitySinceVersion() uint16 {
   387  	return 0
   388  }
   389  
   390  func (r *RecordingStarted) SourceIdentityInActingVersion(actingVersion uint16) bool {
   391  	return actingVersion >= r.SourceIdentitySinceVersion()
   392  }
   393  
   394  func (*RecordingStarted) SourceIdentityDeprecated() uint16 {
   395  	return 0
   396  }
   397  
   398  func (RecordingStarted) SourceIdentityCharacterEncoding() string {
   399  	return "US-ASCII"
   400  }
   401  
   402  func (RecordingStarted) SourceIdentityHeaderLength() uint64 {
   403  	return 4
   404  }