github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/archive/codecs/StopRecordingRequest.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 StopRecordingRequest struct {
    13  	ControlSessionId int64
    14  	CorrelationId    int64
    15  	StreamId         int32
    16  	Channel          []uint8
    17  }
    18  
    19  func (s *StopRecordingRequest) Encode(_m *SbeGoMarshaller, _w io.Writer, doRangeCheck bool) error {
    20  	if doRangeCheck {
    21  		if err := s.RangeCheck(s.SbeSchemaVersion(), s.SbeSchemaVersion()); err != nil {
    22  			return err
    23  		}
    24  	}
    25  	if err := _m.WriteInt64(_w, s.ControlSessionId); err != nil {
    26  		return err
    27  	}
    28  	if err := _m.WriteInt64(_w, s.CorrelationId); err != nil {
    29  		return err
    30  	}
    31  	if err := _m.WriteInt32(_w, s.StreamId); err != nil {
    32  		return err
    33  	}
    34  	if err := _m.WriteUint32(_w, uint32(len(s.Channel))); err != nil {
    35  		return err
    36  	}
    37  	if err := _m.WriteBytes(_w, s.Channel); err != nil {
    38  		return err
    39  	}
    40  	return nil
    41  }
    42  
    43  func (s *StopRecordingRequest) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint16, doRangeCheck bool) error {
    44  	if !s.ControlSessionIdInActingVersion(actingVersion) {
    45  		s.ControlSessionId = s.ControlSessionIdNullValue()
    46  	} else {
    47  		if err := _m.ReadInt64(_r, &s.ControlSessionId); err != nil {
    48  			return err
    49  		}
    50  	}
    51  	if !s.CorrelationIdInActingVersion(actingVersion) {
    52  		s.CorrelationId = s.CorrelationIdNullValue()
    53  	} else {
    54  		if err := _m.ReadInt64(_r, &s.CorrelationId); err != nil {
    55  			return err
    56  		}
    57  	}
    58  	if !s.StreamIdInActingVersion(actingVersion) {
    59  		s.StreamId = s.StreamIdNullValue()
    60  	} else {
    61  		if err := _m.ReadInt32(_r, &s.StreamId); err != nil {
    62  			return err
    63  		}
    64  	}
    65  	if actingVersion > s.SbeSchemaVersion() && blockLength > s.SbeBlockLength() {
    66  		io.CopyN(ioutil.Discard, _r, int64(blockLength-s.SbeBlockLength()))
    67  	}
    68  
    69  	if s.ChannelInActingVersion(actingVersion) {
    70  		var ChannelLength uint32
    71  		if err := _m.ReadUint32(_r, &ChannelLength); err != nil {
    72  			return err
    73  		}
    74  		if cap(s.Channel) < int(ChannelLength) {
    75  			s.Channel = make([]uint8, ChannelLength)
    76  		}
    77  		s.Channel = s.Channel[:ChannelLength]
    78  		if err := _m.ReadBytes(_r, s.Channel); err != nil {
    79  			return err
    80  		}
    81  	}
    82  	if doRangeCheck {
    83  		if err := s.RangeCheck(actingVersion, s.SbeSchemaVersion()); err != nil {
    84  			return err
    85  		}
    86  	}
    87  	return nil
    88  }
    89  
    90  func (s *StopRecordingRequest) RangeCheck(actingVersion uint16, schemaVersion uint16) error {
    91  	if s.ControlSessionIdInActingVersion(actingVersion) {
    92  		if s.ControlSessionId < s.ControlSessionIdMinValue() || s.ControlSessionId > s.ControlSessionIdMaxValue() {
    93  			return fmt.Errorf("Range check failed on s.ControlSessionId (%v < %v > %v)", s.ControlSessionIdMinValue(), s.ControlSessionId, s.ControlSessionIdMaxValue())
    94  		}
    95  	}
    96  	if s.CorrelationIdInActingVersion(actingVersion) {
    97  		if s.CorrelationId < s.CorrelationIdMinValue() || s.CorrelationId > s.CorrelationIdMaxValue() {
    98  			return fmt.Errorf("Range check failed on s.CorrelationId (%v < %v > %v)", s.CorrelationIdMinValue(), s.CorrelationId, s.CorrelationIdMaxValue())
    99  		}
   100  	}
   101  	if s.StreamIdInActingVersion(actingVersion) {
   102  		if s.StreamId < s.StreamIdMinValue() || s.StreamId > s.StreamIdMaxValue() {
   103  			return fmt.Errorf("Range check failed on s.StreamId (%v < %v > %v)", s.StreamIdMinValue(), s.StreamId, s.StreamIdMaxValue())
   104  		}
   105  	}
   106  	return nil
   107  }
   108  
   109  func StopRecordingRequestInit(s *StopRecordingRequest) {
   110  	return
   111  }
   112  
   113  func (*StopRecordingRequest) SbeBlockLength() (blockLength uint16) {
   114  	return 20
   115  }
   116  
   117  func (*StopRecordingRequest) SbeTemplateId() (templateId uint16) {
   118  	return 5
   119  }
   120  
   121  func (*StopRecordingRequest) SbeSchemaId() (schemaId uint16) {
   122  	return 101
   123  }
   124  
   125  func (*StopRecordingRequest) SbeSchemaVersion() (schemaVersion uint16) {
   126  	return 6
   127  }
   128  
   129  func (*StopRecordingRequest) SbeSemanticType() (semanticType []byte) {
   130  	return []byte("")
   131  }
   132  
   133  func (*StopRecordingRequest) ControlSessionIdId() uint16 {
   134  	return 1
   135  }
   136  
   137  func (*StopRecordingRequest) ControlSessionIdSinceVersion() uint16 {
   138  	return 0
   139  }
   140  
   141  func (s *StopRecordingRequest) ControlSessionIdInActingVersion(actingVersion uint16) bool {
   142  	return actingVersion >= s.ControlSessionIdSinceVersion()
   143  }
   144  
   145  func (*StopRecordingRequest) ControlSessionIdDeprecated() uint16 {
   146  	return 0
   147  }
   148  
   149  func (*StopRecordingRequest) ControlSessionIdMetaAttribute(meta int) string {
   150  	switch meta {
   151  	case 1:
   152  		return ""
   153  	case 2:
   154  		return ""
   155  	case 3:
   156  		return ""
   157  	case 4:
   158  		return "required"
   159  	}
   160  	return ""
   161  }
   162  
   163  func (*StopRecordingRequest) ControlSessionIdMinValue() int64 {
   164  	return math.MinInt64 + 1
   165  }
   166  
   167  func (*StopRecordingRequest) ControlSessionIdMaxValue() int64 {
   168  	return math.MaxInt64
   169  }
   170  
   171  func (*StopRecordingRequest) ControlSessionIdNullValue() int64 {
   172  	return math.MinInt64
   173  }
   174  
   175  func (*StopRecordingRequest) CorrelationIdId() uint16 {
   176  	return 2
   177  }
   178  
   179  func (*StopRecordingRequest) CorrelationIdSinceVersion() uint16 {
   180  	return 0
   181  }
   182  
   183  func (s *StopRecordingRequest) CorrelationIdInActingVersion(actingVersion uint16) bool {
   184  	return actingVersion >= s.CorrelationIdSinceVersion()
   185  }
   186  
   187  func (*StopRecordingRequest) CorrelationIdDeprecated() uint16 {
   188  	return 0
   189  }
   190  
   191  func (*StopRecordingRequest) CorrelationIdMetaAttribute(meta int) string {
   192  	switch meta {
   193  	case 1:
   194  		return ""
   195  	case 2:
   196  		return ""
   197  	case 3:
   198  		return ""
   199  	case 4:
   200  		return "required"
   201  	}
   202  	return ""
   203  }
   204  
   205  func (*StopRecordingRequest) CorrelationIdMinValue() int64 {
   206  	return math.MinInt64 + 1
   207  }
   208  
   209  func (*StopRecordingRequest) CorrelationIdMaxValue() int64 {
   210  	return math.MaxInt64
   211  }
   212  
   213  func (*StopRecordingRequest) CorrelationIdNullValue() int64 {
   214  	return math.MinInt64
   215  }
   216  
   217  func (*StopRecordingRequest) StreamIdId() uint16 {
   218  	return 3
   219  }
   220  
   221  func (*StopRecordingRequest) StreamIdSinceVersion() uint16 {
   222  	return 0
   223  }
   224  
   225  func (s *StopRecordingRequest) StreamIdInActingVersion(actingVersion uint16) bool {
   226  	return actingVersion >= s.StreamIdSinceVersion()
   227  }
   228  
   229  func (*StopRecordingRequest) StreamIdDeprecated() uint16 {
   230  	return 0
   231  }
   232  
   233  func (*StopRecordingRequest) StreamIdMetaAttribute(meta int) string {
   234  	switch meta {
   235  	case 1:
   236  		return ""
   237  	case 2:
   238  		return ""
   239  	case 3:
   240  		return ""
   241  	case 4:
   242  		return "required"
   243  	}
   244  	return ""
   245  }
   246  
   247  func (*StopRecordingRequest) StreamIdMinValue() int32 {
   248  	return math.MinInt32 + 1
   249  }
   250  
   251  func (*StopRecordingRequest) StreamIdMaxValue() int32 {
   252  	return math.MaxInt32
   253  }
   254  
   255  func (*StopRecordingRequest) StreamIdNullValue() int32 {
   256  	return math.MinInt32
   257  }
   258  
   259  func (*StopRecordingRequest) ChannelMetaAttribute(meta int) string {
   260  	switch meta {
   261  	case 1:
   262  		return ""
   263  	case 2:
   264  		return ""
   265  	case 3:
   266  		return ""
   267  	case 4:
   268  		return "required"
   269  	}
   270  	return ""
   271  }
   272  
   273  func (*StopRecordingRequest) ChannelSinceVersion() uint16 {
   274  	return 0
   275  }
   276  
   277  func (s *StopRecordingRequest) ChannelInActingVersion(actingVersion uint16) bool {
   278  	return actingVersion >= s.ChannelSinceVersion()
   279  }
   280  
   281  func (*StopRecordingRequest) ChannelDeprecated() uint16 {
   282  	return 0
   283  }
   284  
   285  func (StopRecordingRequest) ChannelCharacterEncoding() string {
   286  	return "US-ASCII"
   287  }
   288  
   289  func (StopRecordingRequest) ChannelHeaderLength() uint64 {
   290  	return 4
   291  }