github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/archive/codecs/RecordingStopped.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 RecordingStopped struct {
    13  	RecordingId   int64
    14  	StartPosition int64
    15  	StopPosition  int64
    16  }
    17  
    18  func (r *RecordingStopped) Encode(_m *SbeGoMarshaller, _w io.Writer, doRangeCheck bool) error {
    19  	if doRangeCheck {
    20  		if err := r.RangeCheck(r.SbeSchemaVersion(), r.SbeSchemaVersion()); err != nil {
    21  			return err
    22  		}
    23  	}
    24  	if err := _m.WriteInt64(_w, r.RecordingId); err != nil {
    25  		return err
    26  	}
    27  	if err := _m.WriteInt64(_w, r.StartPosition); err != nil {
    28  		return err
    29  	}
    30  	if err := _m.WriteInt64(_w, r.StopPosition); err != nil {
    31  		return err
    32  	}
    33  	return nil
    34  }
    35  
    36  func (r *RecordingStopped) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint16, doRangeCheck bool) error {
    37  	if !r.RecordingIdInActingVersion(actingVersion) {
    38  		r.RecordingId = r.RecordingIdNullValue()
    39  	} else {
    40  		if err := _m.ReadInt64(_r, &r.RecordingId); err != nil {
    41  			return err
    42  		}
    43  	}
    44  	if !r.StartPositionInActingVersion(actingVersion) {
    45  		r.StartPosition = r.StartPositionNullValue()
    46  	} else {
    47  		if err := _m.ReadInt64(_r, &r.StartPosition); err != nil {
    48  			return err
    49  		}
    50  	}
    51  	if !r.StopPositionInActingVersion(actingVersion) {
    52  		r.StopPosition = r.StopPositionNullValue()
    53  	} else {
    54  		if err := _m.ReadInt64(_r, &r.StopPosition); err != nil {
    55  			return err
    56  		}
    57  	}
    58  	if actingVersion > r.SbeSchemaVersion() && blockLength > r.SbeBlockLength() {
    59  		io.CopyN(ioutil.Discard, _r, int64(blockLength-r.SbeBlockLength()))
    60  	}
    61  	if doRangeCheck {
    62  		if err := r.RangeCheck(actingVersion, r.SbeSchemaVersion()); err != nil {
    63  			return err
    64  		}
    65  	}
    66  	return nil
    67  }
    68  
    69  func (r *RecordingStopped) RangeCheck(actingVersion uint16, schemaVersion uint16) error {
    70  	if r.RecordingIdInActingVersion(actingVersion) {
    71  		if r.RecordingId < r.RecordingIdMinValue() || r.RecordingId > r.RecordingIdMaxValue() {
    72  			return fmt.Errorf("Range check failed on r.RecordingId (%v < %v > %v)", r.RecordingIdMinValue(), r.RecordingId, r.RecordingIdMaxValue())
    73  		}
    74  	}
    75  	if r.StartPositionInActingVersion(actingVersion) {
    76  		if r.StartPosition < r.StartPositionMinValue() || r.StartPosition > r.StartPositionMaxValue() {
    77  			return fmt.Errorf("Range check failed on r.StartPosition (%v < %v > %v)", r.StartPositionMinValue(), r.StartPosition, r.StartPositionMaxValue())
    78  		}
    79  	}
    80  	if r.StopPositionInActingVersion(actingVersion) {
    81  		if r.StopPosition < r.StopPositionMinValue() || r.StopPosition > r.StopPositionMaxValue() {
    82  			return fmt.Errorf("Range check failed on r.StopPosition (%v < %v > %v)", r.StopPositionMinValue(), r.StopPosition, r.StopPositionMaxValue())
    83  		}
    84  	}
    85  	return nil
    86  }
    87  
    88  func RecordingStoppedInit(r *RecordingStopped) {
    89  	return
    90  }
    91  
    92  func (*RecordingStopped) SbeBlockLength() (blockLength uint16) {
    93  	return 24
    94  }
    95  
    96  func (*RecordingStopped) SbeTemplateId() (templateId uint16) {
    97  	return 103
    98  }
    99  
   100  func (*RecordingStopped) SbeSchemaId() (schemaId uint16) {
   101  	return 101
   102  }
   103  
   104  func (*RecordingStopped) SbeSchemaVersion() (schemaVersion uint16) {
   105  	return 6
   106  }
   107  
   108  func (*RecordingStopped) SbeSemanticType() (semanticType []byte) {
   109  	return []byte("")
   110  }
   111  
   112  func (*RecordingStopped) RecordingIdId() uint16 {
   113  	return 1
   114  }
   115  
   116  func (*RecordingStopped) RecordingIdSinceVersion() uint16 {
   117  	return 0
   118  }
   119  
   120  func (r *RecordingStopped) RecordingIdInActingVersion(actingVersion uint16) bool {
   121  	return actingVersion >= r.RecordingIdSinceVersion()
   122  }
   123  
   124  func (*RecordingStopped) RecordingIdDeprecated() uint16 {
   125  	return 0
   126  }
   127  
   128  func (*RecordingStopped) RecordingIdMetaAttribute(meta int) string {
   129  	switch meta {
   130  	case 1:
   131  		return ""
   132  	case 2:
   133  		return ""
   134  	case 3:
   135  		return ""
   136  	case 4:
   137  		return "required"
   138  	}
   139  	return ""
   140  }
   141  
   142  func (*RecordingStopped) RecordingIdMinValue() int64 {
   143  	return math.MinInt64 + 1
   144  }
   145  
   146  func (*RecordingStopped) RecordingIdMaxValue() int64 {
   147  	return math.MaxInt64
   148  }
   149  
   150  func (*RecordingStopped) RecordingIdNullValue() int64 {
   151  	return math.MinInt64
   152  }
   153  
   154  func (*RecordingStopped) StartPositionId() uint16 {
   155  	return 2
   156  }
   157  
   158  func (*RecordingStopped) StartPositionSinceVersion() uint16 {
   159  	return 0
   160  }
   161  
   162  func (r *RecordingStopped) StartPositionInActingVersion(actingVersion uint16) bool {
   163  	return actingVersion >= r.StartPositionSinceVersion()
   164  }
   165  
   166  func (*RecordingStopped) StartPositionDeprecated() uint16 {
   167  	return 0
   168  }
   169  
   170  func (*RecordingStopped) StartPositionMetaAttribute(meta int) string {
   171  	switch meta {
   172  	case 1:
   173  		return ""
   174  	case 2:
   175  		return ""
   176  	case 3:
   177  		return ""
   178  	case 4:
   179  		return "required"
   180  	}
   181  	return ""
   182  }
   183  
   184  func (*RecordingStopped) StartPositionMinValue() int64 {
   185  	return math.MinInt64 + 1
   186  }
   187  
   188  func (*RecordingStopped) StartPositionMaxValue() int64 {
   189  	return math.MaxInt64
   190  }
   191  
   192  func (*RecordingStopped) StartPositionNullValue() int64 {
   193  	return math.MinInt64
   194  }
   195  
   196  func (*RecordingStopped) StopPositionId() uint16 {
   197  	return 3
   198  }
   199  
   200  func (*RecordingStopped) StopPositionSinceVersion() uint16 {
   201  	return 0
   202  }
   203  
   204  func (r *RecordingStopped) StopPositionInActingVersion(actingVersion uint16) bool {
   205  	return actingVersion >= r.StopPositionSinceVersion()
   206  }
   207  
   208  func (*RecordingStopped) StopPositionDeprecated() uint16 {
   209  	return 0
   210  }
   211  
   212  func (*RecordingStopped) StopPositionMetaAttribute(meta int) string {
   213  	switch meta {
   214  	case 1:
   215  		return ""
   216  	case 2:
   217  		return ""
   218  	case 3:
   219  		return ""
   220  	case 4:
   221  		return "required"
   222  	}
   223  	return ""
   224  }
   225  
   226  func (*RecordingStopped) StopPositionMinValue() int64 {
   227  	return math.MinInt64 + 1
   228  }
   229  
   230  func (*RecordingStopped) StopPositionMaxValue() int64 {
   231  	return math.MaxInt64
   232  }
   233  
   234  func (*RecordingStopped) StopPositionNullValue() int64 {
   235  	return math.MinInt64
   236  }