github.com/lirm/aeron-go@v0.0.0-20230415210743-920325491dc4/archive/codecs/AuthConnectRequest.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 AuthConnectRequest struct { 13 CorrelationId int64 14 ResponseStreamId int32 15 Version int32 16 ResponseChannel []uint8 17 EncodedCredentials []uint8 18 } 19 20 func (a *AuthConnectRequest) Encode(_m *SbeGoMarshaller, _w io.Writer, doRangeCheck bool) error { 21 if doRangeCheck { 22 if err := a.RangeCheck(a.SbeSchemaVersion(), a.SbeSchemaVersion()); err != nil { 23 return err 24 } 25 } 26 if err := _m.WriteInt64(_w, a.CorrelationId); err != nil { 27 return err 28 } 29 if err := _m.WriteInt32(_w, a.ResponseStreamId); err != nil { 30 return err 31 } 32 if err := _m.WriteInt32(_w, a.Version); err != nil { 33 return err 34 } 35 if err := _m.WriteUint32(_w, uint32(len(a.ResponseChannel))); err != nil { 36 return err 37 } 38 if err := _m.WriteBytes(_w, a.ResponseChannel); err != nil { 39 return err 40 } 41 if err := _m.WriteUint32(_w, uint32(len(a.EncodedCredentials))); err != nil { 42 return err 43 } 44 if err := _m.WriteBytes(_w, a.EncodedCredentials); err != nil { 45 return err 46 } 47 return nil 48 } 49 50 func (a *AuthConnectRequest) Decode(_m *SbeGoMarshaller, _r io.Reader, actingVersion uint16, blockLength uint16, doRangeCheck bool) error { 51 if !a.CorrelationIdInActingVersion(actingVersion) { 52 a.CorrelationId = a.CorrelationIdNullValue() 53 } else { 54 if err := _m.ReadInt64(_r, &a.CorrelationId); err != nil { 55 return err 56 } 57 } 58 if !a.ResponseStreamIdInActingVersion(actingVersion) { 59 a.ResponseStreamId = a.ResponseStreamIdNullValue() 60 } else { 61 if err := _m.ReadInt32(_r, &a.ResponseStreamId); err != nil { 62 return err 63 } 64 } 65 if !a.VersionInActingVersion(actingVersion) { 66 a.Version = a.VersionNullValue() 67 } else { 68 if err := _m.ReadInt32(_r, &a.Version); err != nil { 69 return err 70 } 71 } 72 if actingVersion > a.SbeSchemaVersion() && blockLength > a.SbeBlockLength() { 73 io.CopyN(ioutil.Discard, _r, int64(blockLength-a.SbeBlockLength())) 74 } 75 76 if a.ResponseChannelInActingVersion(actingVersion) { 77 var ResponseChannelLength uint32 78 if err := _m.ReadUint32(_r, &ResponseChannelLength); err != nil { 79 return err 80 } 81 if cap(a.ResponseChannel) < int(ResponseChannelLength) { 82 a.ResponseChannel = make([]uint8, ResponseChannelLength) 83 } 84 a.ResponseChannel = a.ResponseChannel[:ResponseChannelLength] 85 if err := _m.ReadBytes(_r, a.ResponseChannel); err != nil { 86 return err 87 } 88 } 89 90 if a.EncodedCredentialsInActingVersion(actingVersion) { 91 var EncodedCredentialsLength uint32 92 if err := _m.ReadUint32(_r, &EncodedCredentialsLength); err != nil { 93 return err 94 } 95 if cap(a.EncodedCredentials) < int(EncodedCredentialsLength) { 96 a.EncodedCredentials = make([]uint8, EncodedCredentialsLength) 97 } 98 a.EncodedCredentials = a.EncodedCredentials[:EncodedCredentialsLength] 99 if err := _m.ReadBytes(_r, a.EncodedCredentials); err != nil { 100 return err 101 } 102 } 103 if doRangeCheck { 104 if err := a.RangeCheck(actingVersion, a.SbeSchemaVersion()); err != nil { 105 return err 106 } 107 } 108 return nil 109 } 110 111 func (a *AuthConnectRequest) RangeCheck(actingVersion uint16, schemaVersion uint16) error { 112 if a.CorrelationIdInActingVersion(actingVersion) { 113 if a.CorrelationId < a.CorrelationIdMinValue() || a.CorrelationId > a.CorrelationIdMaxValue() { 114 return fmt.Errorf("Range check failed on a.CorrelationId (%v < %v > %v)", a.CorrelationIdMinValue(), a.CorrelationId, a.CorrelationIdMaxValue()) 115 } 116 } 117 if a.ResponseStreamIdInActingVersion(actingVersion) { 118 if a.ResponseStreamId < a.ResponseStreamIdMinValue() || a.ResponseStreamId > a.ResponseStreamIdMaxValue() { 119 return fmt.Errorf("Range check failed on a.ResponseStreamId (%v < %v > %v)", a.ResponseStreamIdMinValue(), a.ResponseStreamId, a.ResponseStreamIdMaxValue()) 120 } 121 } 122 if a.VersionInActingVersion(actingVersion) { 123 if a.Version != a.VersionNullValue() && (a.Version < a.VersionMinValue() || a.Version > a.VersionMaxValue()) { 124 return fmt.Errorf("Range check failed on a.Version (%v < %v > %v)", a.VersionMinValue(), a.Version, a.VersionMaxValue()) 125 } 126 } 127 return nil 128 } 129 130 func AuthConnectRequestInit(a *AuthConnectRequest) { 131 a.Version = 0 132 return 133 } 134 135 func (*AuthConnectRequest) SbeBlockLength() (blockLength uint16) { 136 return 16 137 } 138 139 func (*AuthConnectRequest) SbeTemplateId() (templateId uint16) { 140 return 58 141 } 142 143 func (*AuthConnectRequest) SbeSchemaId() (schemaId uint16) { 144 return 101 145 } 146 147 func (*AuthConnectRequest) SbeSchemaVersion() (schemaVersion uint16) { 148 return 6 149 } 150 151 func (*AuthConnectRequest) SbeSemanticType() (semanticType []byte) { 152 return []byte("") 153 } 154 155 func (*AuthConnectRequest) CorrelationIdId() uint16 { 156 return 1 157 } 158 159 func (*AuthConnectRequest) CorrelationIdSinceVersion() uint16 { 160 return 0 161 } 162 163 func (a *AuthConnectRequest) CorrelationIdInActingVersion(actingVersion uint16) bool { 164 return actingVersion >= a.CorrelationIdSinceVersion() 165 } 166 167 func (*AuthConnectRequest) CorrelationIdDeprecated() uint16 { 168 return 0 169 } 170 171 func (*AuthConnectRequest) CorrelationIdMetaAttribute(meta int) string { 172 switch meta { 173 case 1: 174 return "" 175 case 2: 176 return "" 177 case 3: 178 return "" 179 case 4: 180 return "required" 181 } 182 return "" 183 } 184 185 func (*AuthConnectRequest) CorrelationIdMinValue() int64 { 186 return math.MinInt64 + 1 187 } 188 189 func (*AuthConnectRequest) CorrelationIdMaxValue() int64 { 190 return math.MaxInt64 191 } 192 193 func (*AuthConnectRequest) CorrelationIdNullValue() int64 { 194 return math.MinInt64 195 } 196 197 func (*AuthConnectRequest) ResponseStreamIdId() uint16 { 198 return 2 199 } 200 201 func (*AuthConnectRequest) ResponseStreamIdSinceVersion() uint16 { 202 return 0 203 } 204 205 func (a *AuthConnectRequest) ResponseStreamIdInActingVersion(actingVersion uint16) bool { 206 return actingVersion >= a.ResponseStreamIdSinceVersion() 207 } 208 209 func (*AuthConnectRequest) ResponseStreamIdDeprecated() uint16 { 210 return 0 211 } 212 213 func (*AuthConnectRequest) ResponseStreamIdMetaAttribute(meta int) string { 214 switch meta { 215 case 1: 216 return "" 217 case 2: 218 return "" 219 case 3: 220 return "" 221 case 4: 222 return "required" 223 } 224 return "" 225 } 226 227 func (*AuthConnectRequest) ResponseStreamIdMinValue() int32 { 228 return math.MinInt32 + 1 229 } 230 231 func (*AuthConnectRequest) ResponseStreamIdMaxValue() int32 { 232 return math.MaxInt32 233 } 234 235 func (*AuthConnectRequest) ResponseStreamIdNullValue() int32 { 236 return math.MinInt32 237 } 238 239 func (*AuthConnectRequest) VersionId() uint16 { 240 return 3 241 } 242 243 func (*AuthConnectRequest) VersionSinceVersion() uint16 { 244 return 0 245 } 246 247 func (a *AuthConnectRequest) VersionInActingVersion(actingVersion uint16) bool { 248 return actingVersion >= a.VersionSinceVersion() 249 } 250 251 func (*AuthConnectRequest) VersionDeprecated() uint16 { 252 return 0 253 } 254 255 func (*AuthConnectRequest) VersionMetaAttribute(meta int) string { 256 switch meta { 257 case 1: 258 return "" 259 case 2: 260 return "" 261 case 3: 262 return "" 263 case 4: 264 return "optional" 265 } 266 return "" 267 } 268 269 func (*AuthConnectRequest) VersionMinValue() int32 { 270 return 2 271 } 272 273 func (*AuthConnectRequest) VersionMaxValue() int32 { 274 return 16777215 275 } 276 277 func (*AuthConnectRequest) VersionNullValue() int32 { 278 return 0 279 } 280 281 func (*AuthConnectRequest) ResponseChannelMetaAttribute(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 (*AuthConnectRequest) ResponseChannelSinceVersion() uint16 { 296 return 0 297 } 298 299 func (a *AuthConnectRequest) ResponseChannelInActingVersion(actingVersion uint16) bool { 300 return actingVersion >= a.ResponseChannelSinceVersion() 301 } 302 303 func (*AuthConnectRequest) ResponseChannelDeprecated() uint16 { 304 return 0 305 } 306 307 func (AuthConnectRequest) ResponseChannelCharacterEncoding() string { 308 return "US-ASCII" 309 } 310 311 func (AuthConnectRequest) ResponseChannelHeaderLength() uint64 { 312 return 4 313 } 314 315 func (*AuthConnectRequest) EncodedCredentialsMetaAttribute(meta int) string { 316 switch meta { 317 case 1: 318 return "" 319 case 2: 320 return "" 321 case 3: 322 return "" 323 case 4: 324 return "required" 325 } 326 return "" 327 } 328 329 func (*AuthConnectRequest) EncodedCredentialsSinceVersion() uint16 { 330 return 0 331 } 332 333 func (a *AuthConnectRequest) EncodedCredentialsInActingVersion(actingVersion uint16) bool { 334 return actingVersion >= a.EncodedCredentialsSinceVersion() 335 } 336 337 func (*AuthConnectRequest) EncodedCredentialsDeprecated() uint16 { 338 return 0 339 } 340 341 func (AuthConnectRequest) EncodedCredentialsCharacterEncoding() string { 342 return "null" 343 } 344 345 func (AuthConnectRequest) EncodedCredentialsHeaderLength() uint64 { 346 return 4 347 }