@pulsefield/protocol 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/PROTOCOL_GUIDELINES.md +123 -0
  2. package/Package.swift +34 -0
  3. package/README.md +92 -4
  4. package/buf.yaml +1 -1
  5. package/docs/session-scope.md +27 -0
  6. package/gen/python/pulsefield/protocol/py.typed +1 -0
  7. package/gen/python/pulsefield/protocol/v1/core_pb2.py +34 -0
  8. package/gen/python/pulsefield/protocol/v1/core_pb2.pyi +76 -0
  9. package/gen/python/pulsefield/protocol/v1/envelope_pb2.py +6 -23
  10. package/gen/python/pulsefield/protocol/v1/envelope_pb2.pyi +26 -105
  11. package/gen/python/pulsefield/protocol/v1/inference_pb2.py +48 -0
  12. package/gen/python/pulsefield/protocol/v1/inference_pb2.pyi +160 -0
  13. package/gen/python/pulsefield/protocol/v1/mapper_pb2.py +28 -0
  14. package/gen/python/pulsefield/protocol/v1/mapper_pb2.pyi +23 -0
  15. package/gen/swift/pulsefield/protocol/v1/core.pb.swift +323 -0
  16. package/gen/swift/pulsefield/protocol/v1/envelope.pb.swift +335 -671
  17. package/gen/swift/pulsefield/protocol/v1/inference.pb.swift +929 -0
  18. package/gen/swift/pulsefield/protocol/v1/mapper.pb.swift +143 -0
  19. package/package.json +17 -11
  20. package/proto/pulsefield/protocol/v1/core.proto +57 -0
  21. package/proto/pulsefield/protocol/v1/envelope.proto +30 -58
  22. package/proto/pulsefield/protocol/v1/inference.proto +145 -0
  23. package/proto/pulsefield/protocol/v1/mapper.proto +17 -0
  24. package/pyproject.toml +38 -0
  25. package/tools/check-generated.mjs +222 -0
  26. package/tools/check-python-package.mjs +63 -0
  27. package/tools/ensure-python-typed.mjs +10 -0
  28. package/fixtures/json/v1/audio-request.json +0 -12
  29. package/fixtures/json/v1/hit-object-token-event.json +0 -9
@@ -20,787 +20,451 @@ fileprivate nonisolated struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobu
20
20
  typealias Version = _2
21
21
  }
22
22
 
23
- public nonisolated enum Pulsefield_Protocol_V1_MusicSource: SwiftProtobuf.Enum, Swift.CaseIterable {
24
- public typealias RawValue = Int
25
- case unspecified // = 0
26
- case background // = 1
27
- case systemAudio // = 2
28
- case UNRECOGNIZED(Int)
29
-
30
- public init() {
31
- self = .unspecified
32
- }
23
+ /// Transport-agnostic binary envelope shared by Pulsefield nodes.
24
+ public nonisolated struct Pulsefield_Protocol_V1_Envelope: @unchecked Sendable {
25
+ // SwiftProtobuf.Message conformance is added in an extension below. See the
26
+ // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
27
+ // methods supported on all messages.
33
28
 
34
- public init?(rawValue: Int) {
35
- switch rawValue {
36
- case 0: self = .unspecified
37
- case 1: self = .background
38
- case 2: self = .systemAudio
39
- default: self = .UNRECOGNIZED(rawValue)
40
- }
29
+ /// Inference/play session identifier. Empty for node-level or graph-level messages.
30
+ public var sessionID: String {
31
+ get {_storage._sessionID}
32
+ set {_uniqueStorage()._sessionID = newValue}
41
33
  }
42
34
 
43
- public var rawValue: Int {
44
- switch self {
45
- case .unspecified: return 0
46
- case .background: return 1
47
- case .systemAudio: return 2
48
- case .UNRECOGNIZED(let i): return i
49
- }
35
+ /// Sender-local monotonic sequence number within a session. per source_node_id + session_id
36
+ public var sequence: UInt64 {
37
+ get {_storage._sequence}
38
+ set {_uniqueStorage()._sequence = newValue}
50
39
  }
51
40
 
52
- // The compiler won't synthesize support with the UNRECOGNIZED case.
53
- public static let allCases: [Pulsefield_Protocol_V1_MusicSource] = [
54
- .unspecified,
55
- .background,
56
- .systemAudio,
57
- ]
58
-
59
- }
60
-
61
- public nonisolated enum Pulsefield_Protocol_V1_InferenceRoute: SwiftProtobuf.Enum, Swift.CaseIterable {
62
- public typealias RawValue = Int
63
- case unspecified // = 0
64
- case mapper // = 1
65
- case timingMock // = 2
66
- case UNRECOGNIZED(Int)
67
-
68
- public init() {
69
- self = .unspecified
41
+ /// Sender wall-clock timestamp in Unix milliseconds, when available.
42
+ public var sentAtUnixMs: Int64 {
43
+ get {_storage._sentAtUnixMs}
44
+ set {_uniqueStorage()._sentAtUnixMs = newValue}
70
45
  }
71
46
 
72
- public init?(rawValue: Int) {
73
- switch rawValue {
74
- case 0: self = .unspecified
75
- case 1: self = .mapper
76
- case 2: self = .timingMock
77
- default: self = .UNRECOGNIZED(rawValue)
78
- }
47
+ /// Node that produced this envelope, when the transport has graph identity.
48
+ public var sourceNodeID: String {
49
+ get {_storage._sourceNodeID}
50
+ set {_uniqueStorage()._sourceNodeID = newValue}
79
51
  }
80
52
 
81
- public var rawValue: Int {
82
- switch self {
83
- case .unspecified: return 0
84
- case .mapper: return 1
85
- case .timingMock: return 2
86
- case .UNRECOGNIZED(let i): return i
87
- }
53
+ /// Intended recipient node. Empty means the session or transport decides routing.
54
+ public var targetNodeID: String {
55
+ get {_storage._targetNodeID}
56
+ set {_uniqueStorage()._targetNodeID = newValue}
88
57
  }
89
58
 
90
- // The compiler won't synthesize support with the UNRECOGNIZED case.
91
- public static let allCases: [Pulsefield_Protocol_V1_InferenceRoute] = [
92
- .unspecified,
93
- .mapper,
94
- .timingMock,
95
- ]
96
-
97
- }
59
+ /// globally unique enough, sender-generated
60
+ public var messageID: String {
61
+ get {_storage._messageID}
62
+ set {_uniqueStorage()._messageID = newValue}
63
+ }
98
64
 
99
- public nonisolated enum Pulsefield_Protocol_V1_EndpointStatus: SwiftProtobuf.Enum, Swift.CaseIterable {
100
- public typealias RawValue = Int
101
- case unspecified // = 0
102
- case ready // = 1
103
- case audioPreparing // = 2
104
- case audioReady // = 3
105
- case streaming // = 4
106
- case stopped // = 5
107
- case UNRECOGNIZED(Int)
108
-
109
- public init() {
110
- self = .unspecified
65
+ /// Related message or request identifier for response and stream correlation.
66
+ public var correlationID: String {
67
+ get {_storage._correlationID}
68
+ set {_uniqueStorage()._correlationID = newValue}
111
69
  }
112
70
 
113
- public init?(rawValue: Int) {
114
- switch rawValue {
115
- case 0: self = .unspecified
116
- case 1: self = .ready
117
- case 2: self = .audioPreparing
118
- case 3: self = .audioReady
119
- case 4: self = .streaming
120
- case 5: self = .stopped
121
- default: self = .UNRECOGNIZED(rawValue)
122
- }
71
+ public var payload: OneOf_Payload? {
72
+ get {return _storage._payload}
73
+ set {_uniqueStorage()._payload = newValue}
123
74
  }
124
75
 
125
- public var rawValue: Int {
126
- switch self {
127
- case .unspecified: return 0
128
- case .ready: return 1
129
- case .audioPreparing: return 2
130
- case .audioReady: return 3
131
- case .streaming: return 4
132
- case .stopped: return 5
133
- case .UNRECOGNIZED(let i): return i
76
+ /// Graph identity announcement, usually sent before domain-specific traffic.
77
+ public var nodeHello: Pulsefield_Protocol_V1_NodeHello {
78
+ get {
79
+ if case .nodeHello(let v)? = _storage._payload {return v}
80
+ return Pulsefield_Protocol_V1_NodeHello()
134
81
  }
82
+ set {_uniqueStorage()._payload = .nodeHello(newValue)}
135
83
  }
136
84
 
137
- // The compiler won't synthesize support with the UNRECOGNIZED case.
138
- public static let allCases: [Pulsefield_Protocol_V1_EndpointStatus] = [
139
- .unspecified,
140
- .ready,
141
- .audioPreparing,
142
- .audioReady,
143
- .streaming,
144
- .stopped,
145
- ]
146
-
147
- }
148
-
149
- public nonisolated struct Pulsefield_Protocol_V1_Envelope: Sendable {
150
- // SwiftProtobuf.Message conformance is added in an extension below. See the
151
- // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
152
- // methods supported on all messages.
153
-
154
- public var sessionID: String = String()
155
-
156
- public var sequence: UInt64 = 0
157
-
158
- public var sentAtUnixMs: Int64 = 0
159
-
160
- public var payload: Pulsefield_Protocol_V1_Envelope.OneOf_Payload? = nil
161
-
162
85
  public var ready: Pulsefield_Protocol_V1_ReadyRequest {
163
86
  get {
164
- if case .ready(let v)? = payload {return v}
87
+ if case .ready(let v)? = _storage._payload {return v}
165
88
  return Pulsefield_Protocol_V1_ReadyRequest()
166
89
  }
167
- set {payload = .ready(newValue)}
90
+ set {_uniqueStorage()._payload = .ready(newValue)}
168
91
  }
169
92
 
170
93
  public var audio: Pulsefield_Protocol_V1_AudioRequest {
171
94
  get {
172
- if case .audio(let v)? = payload {return v}
95
+ if case .audio(let v)? = _storage._payload {return v}
173
96
  return Pulsefield_Protocol_V1_AudioRequest()
174
97
  }
175
- set {payload = .audio(newValue)}
98
+ set {_uniqueStorage()._payload = .audio(newValue)}
176
99
  }
177
100
 
178
101
  public var referenceTime: Pulsefield_Protocol_V1_ReferenceTimeRequest {
179
102
  get {
180
- if case .referenceTime(let v)? = payload {return v}
103
+ if case .referenceTime(let v)? = _storage._payload {return v}
181
104
  return Pulsefield_Protocol_V1_ReferenceTimeRequest()
182
105
  }
183
- set {payload = .referenceTime(newValue)}
106
+ set {_uniqueStorage()._payload = .referenceTime(newValue)}
184
107
  }
185
108
 
186
109
  public var stopSession: Pulsefield_Protocol_V1_StopSessionRequest {
187
110
  get {
188
- if case .stopSession(let v)? = payload {return v}
111
+ if case .stopSession(let v)? = _storage._payload {return v}
189
112
  return Pulsefield_Protocol_V1_StopSessionRequest()
190
113
  }
191
- set {payload = .stopSession(newValue)}
114
+ set {_uniqueStorage()._payload = .stopSession(newValue)}
115
+ }
116
+
117
+ /// One mapper token event. The legacy JSON transport calls this hitobject_tokens.
118
+ public var mapperStreamBegin: Pulsefield_Protocol_V1_MapperStreamBeginEvent {
119
+ get {
120
+ if case .mapperStreamBegin(let v)? = _storage._payload {return v}
121
+ return Pulsefield_Protocol_V1_MapperStreamBeginEvent()
122
+ }
123
+ set {_uniqueStorage()._payload = .mapperStreamBegin(newValue)}
192
124
  }
193
125
 
194
126
  public var hitObjectToken: Pulsefield_Protocol_V1_HitObjectTokenEvent {
195
127
  get {
196
- if case .hitObjectToken(let v)? = payload {return v}
128
+ if case .hitObjectToken(let v)? = _storage._payload {return v}
197
129
  return Pulsefield_Protocol_V1_HitObjectTokenEvent()
198
130
  }
199
- set {payload = .hitObjectToken(newValue)}
131
+ set {_uniqueStorage()._payload = .hitObjectToken(newValue)}
200
132
  }
201
133
 
202
134
  public var error: Pulsefield_Protocol_V1_ErrorEvent {
203
135
  get {
204
- if case .error(let v)? = payload {return v}
136
+ if case .error(let v)? = _storage._payload {return v}
205
137
  return Pulsefield_Protocol_V1_ErrorEvent()
206
138
  }
207
- set {payload = .error(newValue)}
139
+ set {_uniqueStorage()._payload = .error(newValue)}
208
140
  }
209
141
 
210
142
  public var status: Pulsefield_Protocol_V1_StatusEvent {
211
143
  get {
212
- if case .status(let v)? = payload {return v}
144
+ if case .status(let v)? = _storage._payload {return v}
213
145
  return Pulsefield_Protocol_V1_StatusEvent()
214
146
  }
215
- set {payload = .status(newValue)}
147
+ set {_uniqueStorage()._payload = .status(newValue)}
148
+ }
149
+
150
+ public var endOfStream: Pulsefield_Protocol_V1_EndOfStreamEvent {
151
+ get {
152
+ if case .endOfStream(let v)? = _storage._payload {return v}
153
+ return Pulsefield_Protocol_V1_EndOfStreamEvent()
154
+ }
155
+ set {_uniqueStorage()._payload = .endOfStream(newValue)}
216
156
  }
217
157
 
218
158
  public var unknownFields = SwiftProtobuf.UnknownStorage()
219
159
 
220
160
  public nonisolated enum OneOf_Payload: Equatable, Sendable {
161
+ /// Graph identity announcement, usually sent before domain-specific traffic.
162
+ case nodeHello(Pulsefield_Protocol_V1_NodeHello)
221
163
  case ready(Pulsefield_Protocol_V1_ReadyRequest)
222
164
  case audio(Pulsefield_Protocol_V1_AudioRequest)
223
165
  case referenceTime(Pulsefield_Protocol_V1_ReferenceTimeRequest)
224
166
  case stopSession(Pulsefield_Protocol_V1_StopSessionRequest)
167
+ /// One mapper token event. The legacy JSON transport calls this hitobject_tokens.
168
+ case mapperStreamBegin(Pulsefield_Protocol_V1_MapperStreamBeginEvent)
225
169
  case hitObjectToken(Pulsefield_Protocol_V1_HitObjectTokenEvent)
226
170
  case error(Pulsefield_Protocol_V1_ErrorEvent)
227
171
  case status(Pulsefield_Protocol_V1_StatusEvent)
172
+ case endOfStream(Pulsefield_Protocol_V1_EndOfStreamEvent)
228
173
 
229
174
  }
230
175
 
231
176
  public init() {}
232
- }
233
177
 
234
- public nonisolated struct Pulsefield_Protocol_V1_ReadyRequest: Sendable {
235
- // SwiftProtobuf.Message conformance is added in an extension below. See the
236
- // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
237
- // methods supported on all messages.
238
-
239
- public var unknownFields = SwiftProtobuf.UnknownStorage()
240
-
241
- public init() {}
242
- }
243
-
244
- public nonisolated struct Pulsefield_Protocol_V1_AudioRequest: Sendable {
245
- // SwiftProtobuf.Message conformance is added in an extension below. See the
246
- // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
247
- // methods supported on all messages.
248
-
249
- public var audioPath: String = String()
250
-
251
- public var audioLengthMs: UInt32 {
252
- get {_audioLengthMs ?? 0}
253
- set {_audioLengthMs = newValue}
254
- }
255
- /// Returns true if `audioLengthMs` has been explicitly set.
256
- public var hasAudioLengthMs: Bool {self._audioLengthMs != nil}
257
- /// Clears the value of `audioLengthMs`. Subsequent reads from it will return its default value.
258
- public mutating func clearAudioLengthMs() {self._audioLengthMs = nil}
259
-
260
- public var musicSource: Pulsefield_Protocol_V1_MusicSource = .unspecified
261
-
262
- public var difficulty: Double {
263
- get {_difficulty ?? 0}
264
- set {_difficulty = newValue}
265
- }
266
- /// Returns true if `difficulty` has been explicitly set.
267
- public var hasDifficulty: Bool {self._difficulty != nil}
268
- /// Clears the value of `difficulty`. Subsequent reads from it will return its default value.
269
- public mutating func clearDifficulty() {self._difficulty = nil}
270
-
271
- public var route: Pulsefield_Protocol_V1_InferenceRoute = .unspecified
272
-
273
- public var unknownFields = SwiftProtobuf.UnknownStorage()
274
-
275
- public init() {}
276
-
277
- fileprivate var _audioLengthMs: UInt32? = nil
278
- fileprivate var _difficulty: Double? = nil
279
- }
280
-
281
- public nonisolated struct Pulsefield_Protocol_V1_ReferenceTimeRequest: Sendable {
282
- // SwiftProtobuf.Message conformance is added in an extension below. See the
283
- // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
284
- // methods supported on all messages.
285
-
286
- public var refTimeMs: UInt32 = 0
287
-
288
- public var localHostTimeSendMs: Double = 0
289
-
290
- public var audioLengthMs: UInt32 {
291
- get {_audioLengthMs ?? 0}
292
- set {_audioLengthMs = newValue}
293
- }
294
- /// Returns true if `audioLengthMs` has been explicitly set.
295
- public var hasAudioLengthMs: Bool {self._audioLengthMs != nil}
296
- /// Clears the value of `audioLengthMs`. Subsequent reads from it will return its default value.
297
- public mutating func clearAudioLengthMs() {self._audioLengthMs = nil}
298
-
299
- public var unknownFields = SwiftProtobuf.UnknownStorage()
300
-
301
- public init() {}
302
-
303
- fileprivate var _audioLengthMs: UInt32? = nil
304
- }
305
-
306
- public nonisolated struct Pulsefield_Protocol_V1_StopSessionRequest: Sendable {
307
- // SwiftProtobuf.Message conformance is added in an extension below. See the
308
- // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
309
- // methods supported on all messages.
310
-
311
- public var reason: String = String()
312
-
313
- public var unknownFields = SwiftProtobuf.UnknownStorage()
314
-
315
- public init() {}
316
- }
317
-
318
- public nonisolated struct Pulsefield_Protocol_V1_HitObjectTokenEvent: Sendable {
319
- // SwiftProtobuf.Message conformance is added in an extension below. See the
320
- // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
321
- // methods supported on all messages.
322
-
323
- public var tokenID: UInt32 = 0
324
-
325
- public var msInRefAudio: UInt32 = 0
326
-
327
- public var unknownFields = SwiftProtobuf.UnknownStorage()
328
-
329
- public init() {}
330
- }
331
-
332
- public nonisolated struct Pulsefield_Protocol_V1_ErrorEvent: Sendable {
333
- // SwiftProtobuf.Message conformance is added in an extension below. See the
334
- // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
335
- // methods supported on all messages.
336
-
337
- public var code: String = String()
338
-
339
- public var message: String = String()
340
-
341
- public var unknownFields = SwiftProtobuf.UnknownStorage()
342
-
343
- public init() {}
344
- }
345
-
346
- public nonisolated struct Pulsefield_Protocol_V1_StatusEvent: Sendable {
347
- // SwiftProtobuf.Message conformance is added in an extension below. See the
348
- // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
349
- // methods supported on all messages.
350
-
351
- public var status: Pulsefield_Protocol_V1_EndpointStatus = .unspecified
352
-
353
- public var message: String = String()
354
-
355
- public var refTimeMs: UInt32 = 0
356
-
357
- public var localHostTimeMs: Double = 0
358
-
359
- public var unknownFields = SwiftProtobuf.UnknownStorage()
360
-
361
- public init() {}
178
+ fileprivate var _storage = _StorageClass.defaultInstance
362
179
  }
363
180
 
364
181
  // MARK: - Code below here is support for the SwiftProtobuf runtime.
365
182
 
366
183
  fileprivate nonisolated let _protobuf_package = "pulsefield.protocol.v1"
367
184
 
368
- nonisolated extension Pulsefield_Protocol_V1_MusicSource: SwiftProtobuf._ProtoNameProviding {
369
- public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0MUSIC_SOURCE_UNSPECIFIED\0\u{1}MUSIC_SOURCE_BACKGROUND\0\u{1}MUSIC_SOURCE_SYSTEM_AUDIO\0")
370
- }
371
-
372
- nonisolated extension Pulsefield_Protocol_V1_InferenceRoute: SwiftProtobuf._ProtoNameProviding {
373
- public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0INFERENCE_ROUTE_UNSPECIFIED\0\u{1}INFERENCE_ROUTE_MAPPER\0\u{1}INFERENCE_ROUTE_TIMING_MOCK\0")
374
- }
375
-
376
- nonisolated extension Pulsefield_Protocol_V1_EndpointStatus: SwiftProtobuf._ProtoNameProviding {
377
- public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\0ENDPOINT_STATUS_UNSPECIFIED\0\u{1}ENDPOINT_STATUS_READY\0\u{1}ENDPOINT_STATUS_AUDIO_PREPARING\0\u{1}ENDPOINT_STATUS_AUDIO_READY\0\u{1}ENDPOINT_STATUS_STREAMING\0\u{1}ENDPOINT_STATUS_STOPPED\0")
378
- }
379
-
380
185
  nonisolated extension Pulsefield_Protocol_V1_Envelope: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
381
186
  public static let protoMessageName: String = _protobuf_package + ".Envelope"
382
- public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}session_id\0\u{1}sequence\0\u{3}sent_at_unix_ms\0\u{2}\u{7}ready\0\u{1}audio\0\u{3}reference_time\0\u{3}stop_session\0\u{4}\u{7}hit_object_token\0\u{1}error\0\u{1}status\0")
187
+ public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}session_id\0\u{1}sequence\0\u{3}sent_at_unix_ms\0\u{3}source_node_id\0\u{3}target_node_id\0\u{3}message_id\0\u{3}correlation_id\0\u{3}node_hello\0\u{2}\u{2}ready\0\u{1}audio\0\u{3}reference_time\0\u{3}stop_session\0\u{4}\u{6}mapper_stream_begin\0\u{3}hit_object_token\0\u{1}error\0\u{1}status\0\u{3}end_of_stream\0")
383
188
 
384
- public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
385
- while let fieldNumber = try decoder.nextFieldNumber() {
386
- // The use of inline closures is to circumvent an issue where the compiler
387
- // allocates stack space for every case branch when no optimizations are
388
- // enabled. https://github.com/apple/swift-protobuf/issues/1034
389
- switch fieldNumber {
390
- case 1: try { try decoder.decodeSingularStringField(value: &self.sessionID) }()
391
- case 2: try { try decoder.decodeSingularUInt64Field(value: &self.sequence) }()
392
- case 3: try { try decoder.decodeSingularInt64Field(value: &self.sentAtUnixMs) }()
393
- case 10: try {
394
- var v: Pulsefield_Protocol_V1_ReadyRequest?
395
- var hadOneofValue = false
396
- if let current = self.payload {
397
- hadOneofValue = true
398
- if case .ready(let m) = current {v = m}
399
- }
400
- try decoder.decodeSingularMessageField(value: &v)
401
- if let v = v {
402
- if hadOneofValue {try decoder.handleConflictingOneOf()}
403
- self.payload = .ready(v)
404
- }
405
- }()
406
- case 11: try {
407
- var v: Pulsefield_Protocol_V1_AudioRequest?
408
- var hadOneofValue = false
409
- if let current = self.payload {
410
- hadOneofValue = true
411
- if case .audio(let m) = current {v = m}
412
- }
413
- try decoder.decodeSingularMessageField(value: &v)
414
- if let v = v {
415
- if hadOneofValue {try decoder.handleConflictingOneOf()}
416
- self.payload = .audio(v)
417
- }
418
- }()
419
- case 12: try {
420
- var v: Pulsefield_Protocol_V1_ReferenceTimeRequest?
421
- var hadOneofValue = false
422
- if let current = self.payload {
423
- hadOneofValue = true
424
- if case .referenceTime(let m) = current {v = m}
425
- }
426
- try decoder.decodeSingularMessageField(value: &v)
427
- if let v = v {
428
- if hadOneofValue {try decoder.handleConflictingOneOf()}
429
- self.payload = .referenceTime(v)
430
- }
431
- }()
432
- case 13: try {
433
- var v: Pulsefield_Protocol_V1_StopSessionRequest?
434
- var hadOneofValue = false
435
- if let current = self.payload {
436
- hadOneofValue = true
437
- if case .stopSession(let m) = current {v = m}
438
- }
439
- try decoder.decodeSingularMessageField(value: &v)
440
- if let v = v {
441
- if hadOneofValue {try decoder.handleConflictingOneOf()}
442
- self.payload = .stopSession(v)
443
- }
444
- }()
445
- case 20: try {
446
- var v: Pulsefield_Protocol_V1_HitObjectTokenEvent?
447
- var hadOneofValue = false
448
- if let current = self.payload {
449
- hadOneofValue = true
450
- if case .hitObjectToken(let m) = current {v = m}
451
- }
452
- try decoder.decodeSingularMessageField(value: &v)
453
- if let v = v {
454
- if hadOneofValue {try decoder.handleConflictingOneOf()}
455
- self.payload = .hitObjectToken(v)
456
- }
457
- }()
458
- case 21: try {
459
- var v: Pulsefield_Protocol_V1_ErrorEvent?
460
- var hadOneofValue = false
461
- if let current = self.payload {
462
- hadOneofValue = true
463
- if case .error(let m) = current {v = m}
464
- }
465
- try decoder.decodeSingularMessageField(value: &v)
466
- if let v = v {
467
- if hadOneofValue {try decoder.handleConflictingOneOf()}
468
- self.payload = .error(v)
469
- }
470
- }()
471
- case 22: try {
472
- var v: Pulsefield_Protocol_V1_StatusEvent?
473
- var hadOneofValue = false
474
- if let current = self.payload {
475
- hadOneofValue = true
476
- if case .status(let m) = current {v = m}
477
- }
478
- try decoder.decodeSingularMessageField(value: &v)
479
- if let v = v {
480
- if hadOneofValue {try decoder.handleConflictingOneOf()}
481
- self.payload = .status(v)
482
- }
483
- }()
484
- default: break
485
- }
486
- }
487
- }
189
+ fileprivate class _StorageClass {
190
+ var _sessionID: String = String()
191
+ var _sequence: UInt64 = 0
192
+ var _sentAtUnixMs: Int64 = 0
193
+ var _sourceNodeID: String = String()
194
+ var _targetNodeID: String = String()
195
+ var _messageID: String = String()
196
+ var _correlationID: String = String()
197
+ var _payload: Pulsefield_Protocol_V1_Envelope.OneOf_Payload?
488
198
 
489
- public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
490
- // The use of inline closures is to circumvent an issue where the compiler
491
- // allocates stack space for every if/case branch local when no optimizations
492
- // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
493
- // https://github.com/apple/swift-protobuf/issues/1182
494
- if !self.sessionID.isEmpty {
495
- try visitor.visitSingularStringField(value: self.sessionID, fieldNumber: 1)
496
- }
497
- if self.sequence != 0 {
498
- try visitor.visitSingularUInt64Field(value: self.sequence, fieldNumber: 2)
499
- }
500
- if self.sentAtUnixMs != 0 {
501
- try visitor.visitSingularInt64Field(value: self.sentAtUnixMs, fieldNumber: 3)
502
- }
503
- switch self.payload {
504
- case .ready?: try {
505
- guard case .ready(let v)? = self.payload else { preconditionFailure() }
506
- try visitor.visitSingularMessageField(value: v, fieldNumber: 10)
507
- }()
508
- case .audio?: try {
509
- guard case .audio(let v)? = self.payload else { preconditionFailure() }
510
- try visitor.visitSingularMessageField(value: v, fieldNumber: 11)
511
- }()
512
- case .referenceTime?: try {
513
- guard case .referenceTime(let v)? = self.payload else { preconditionFailure() }
514
- try visitor.visitSingularMessageField(value: v, fieldNumber: 12)
515
- }()
516
- case .stopSession?: try {
517
- guard case .stopSession(let v)? = self.payload else { preconditionFailure() }
518
- try visitor.visitSingularMessageField(value: v, fieldNumber: 13)
519
- }()
520
- case .hitObjectToken?: try {
521
- guard case .hitObjectToken(let v)? = self.payload else { preconditionFailure() }
522
- try visitor.visitSingularMessageField(value: v, fieldNumber: 20)
523
- }()
524
- case .error?: try {
525
- guard case .error(let v)? = self.payload else { preconditionFailure() }
526
- try visitor.visitSingularMessageField(value: v, fieldNumber: 21)
527
- }()
528
- case .status?: try {
529
- guard case .status(let v)? = self.payload else { preconditionFailure() }
530
- try visitor.visitSingularMessageField(value: v, fieldNumber: 22)
531
- }()
532
- case nil: break
533
- }
534
- try unknownFields.traverse(visitor: &visitor)
535
- }
199
+ // This property is used as the initial default value for new instances of the type.
200
+ // The type itself is protecting the reference to its storage via CoW semantics.
201
+ // This will force a copy to be made of this reference when the first mutation occurs;
202
+ // hence, it is safe to mark this as `nonisolated(unsafe)`.
203
+ static nonisolated(unsafe) let defaultInstance = _StorageClass()
536
204
 
537
- public static func ==(lhs: Pulsefield_Protocol_V1_Envelope, rhs: Pulsefield_Protocol_V1_Envelope) -> Bool {
538
- if lhs.sessionID != rhs.sessionID {return false}
539
- if lhs.sequence != rhs.sequence {return false}
540
- if lhs.sentAtUnixMs != rhs.sentAtUnixMs {return false}
541
- if lhs.payload != rhs.payload {return false}
542
- if lhs.unknownFields != rhs.unknownFields {return false}
543
- return true
544
- }
545
- }
205
+ private init() {}
546
206
 
547
- nonisolated extension Pulsefield_Protocol_V1_ReadyRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
548
- public static let protoMessageName: String = _protobuf_package + ".ReadyRequest"
549
- public static let _protobuf_nameMap = SwiftProtobuf._NameMap()
550
-
551
- public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
552
- // Load everything into unknown fields
553
- while try decoder.nextFieldNumber() != nil {}
554
- }
555
-
556
- public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
557
- try unknownFields.traverse(visitor: &visitor)
558
- }
559
-
560
- public static func ==(lhs: Pulsefield_Protocol_V1_ReadyRequest, rhs: Pulsefield_Protocol_V1_ReadyRequest) -> Bool {
561
- if lhs.unknownFields != rhs.unknownFields {return false}
562
- return true
563
- }
564
- }
565
-
566
- nonisolated extension Pulsefield_Protocol_V1_AudioRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
567
- public static let protoMessageName: String = _protobuf_package + ".AudioRequest"
568
- public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}audio_path\0\u{3}audio_length_ms\0\u{3}music_source\0\u{1}difficulty\0\u{1}route\0")
569
-
570
- public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
571
- while let fieldNumber = try decoder.nextFieldNumber() {
572
- // The use of inline closures is to circumvent an issue where the compiler
573
- // allocates stack space for every case branch when no optimizations are
574
- // enabled. https://github.com/apple/swift-protobuf/issues/1034
575
- switch fieldNumber {
576
- case 1: try { try decoder.decodeSingularStringField(value: &self.audioPath) }()
577
- case 2: try { try decoder.decodeSingularUInt32Field(value: &self._audioLengthMs) }()
578
- case 3: try { try decoder.decodeSingularEnumField(value: &self.musicSource) }()
579
- case 4: try { try decoder.decodeSingularDoubleField(value: &self._difficulty) }()
580
- case 5: try { try decoder.decodeSingularEnumField(value: &self.route) }()
581
- default: break
582
- }
207
+ init(copying source: _StorageClass) {
208
+ _sessionID = source._sessionID
209
+ _sequence = source._sequence
210
+ _sentAtUnixMs = source._sentAtUnixMs
211
+ _sourceNodeID = source._sourceNodeID
212
+ _targetNodeID = source._targetNodeID
213
+ _messageID = source._messageID
214
+ _correlationID = source._correlationID
215
+ _payload = source._payload
583
216
  }
584
217
  }
585
218
 
586
- public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
587
- // The use of inline closures is to circumvent an issue where the compiler
588
- // allocates stack space for every if/case branch local when no optimizations
589
- // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
590
- // https://github.com/apple/swift-protobuf/issues/1182
591
- if !self.audioPath.isEmpty {
592
- try visitor.visitSingularStringField(value: self.audioPath, fieldNumber: 1)
593
- }
594
- try { if let v = self._audioLengthMs {
595
- try visitor.visitSingularUInt32Field(value: v, fieldNumber: 2)
596
- } }()
597
- if self.musicSource != .unspecified {
598
- try visitor.visitSingularEnumField(value: self.musicSource, fieldNumber: 3)
219
+ fileprivate mutating func _uniqueStorage() -> _StorageClass {
220
+ if !isKnownUniquelyReferenced(&_storage) {
221
+ _storage = _StorageClass(copying: _storage)
599
222
  }
600
- try { if let v = self._difficulty {
601
- try visitor.visitSingularDoubleField(value: v, fieldNumber: 4)
602
- } }()
603
- if self.route != .unspecified {
604
- try visitor.visitSingularEnumField(value: self.route, fieldNumber: 5)
605
- }
606
- try unknownFields.traverse(visitor: &visitor)
607
- }
608
-
609
- public static func ==(lhs: Pulsefield_Protocol_V1_AudioRequest, rhs: Pulsefield_Protocol_V1_AudioRequest) -> Bool {
610
- if lhs.audioPath != rhs.audioPath {return false}
611
- if lhs._audioLengthMs != rhs._audioLengthMs {return false}
612
- if lhs.musicSource != rhs.musicSource {return false}
613
- if lhs._difficulty != rhs._difficulty {return false}
614
- if lhs.route != rhs.route {return false}
615
- if lhs.unknownFields != rhs.unknownFields {return false}
616
- return true
223
+ return _storage
617
224
  }
618
- }
619
-
620
- nonisolated extension Pulsefield_Protocol_V1_ReferenceTimeRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
621
- public static let protoMessageName: String = _protobuf_package + ".ReferenceTimeRequest"
622
- public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}ref_time_ms\0\u{3}local_host_time_send_ms\0\u{3}audio_length_ms\0")
623
225
 
624
226
  public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
625
- while let fieldNumber = try decoder.nextFieldNumber() {
626
- // The use of inline closures is to circumvent an issue where the compiler
627
- // allocates stack space for every case branch when no optimizations are
628
- // enabled. https://github.com/apple/swift-protobuf/issues/1034
629
- switch fieldNumber {
630
- case 1: try { try decoder.decodeSingularUInt32Field(value: &self.refTimeMs) }()
631
- case 2: try { try decoder.decodeSingularDoubleField(value: &self.localHostTimeSendMs) }()
632
- case 3: try { try decoder.decodeSingularUInt32Field(value: &self._audioLengthMs) }()
633
- default: break
227
+ _ = _uniqueStorage()
228
+ try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
229
+ while let fieldNumber = try decoder.nextFieldNumber() {
230
+ // The use of inline closures is to circumvent an issue where the compiler
231
+ // allocates stack space for every case branch when no optimizations are
232
+ // enabled. https://github.com/apple/swift-protobuf/issues/1034
233
+ switch fieldNumber {
234
+ case 1: try { try decoder.decodeSingularStringField(value: &_storage._sessionID) }()
235
+ case 2: try { try decoder.decodeSingularUInt64Field(value: &_storage._sequence) }()
236
+ case 3: try { try decoder.decodeSingularInt64Field(value: &_storage._sentAtUnixMs) }()
237
+ case 4: try { try decoder.decodeSingularStringField(value: &_storage._sourceNodeID) }()
238
+ case 5: try { try decoder.decodeSingularStringField(value: &_storage._targetNodeID) }()
239
+ case 6: try { try decoder.decodeSingularStringField(value: &_storage._messageID) }()
240
+ case 7: try { try decoder.decodeSingularStringField(value: &_storage._correlationID) }()
241
+ case 8: try {
242
+ var v: Pulsefield_Protocol_V1_NodeHello?
243
+ var hadOneofValue = false
244
+ if let current = _storage._payload {
245
+ hadOneofValue = true
246
+ if case .nodeHello(let m) = current {v = m}
247
+ }
248
+ try decoder.decodeSingularMessageField(value: &v)
249
+ if let v = v {
250
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
251
+ _storage._payload = .nodeHello(v)
252
+ }
253
+ }()
254
+ case 10: try {
255
+ var v: Pulsefield_Protocol_V1_ReadyRequest?
256
+ var hadOneofValue = false
257
+ if let current = _storage._payload {
258
+ hadOneofValue = true
259
+ if case .ready(let m) = current {v = m}
260
+ }
261
+ try decoder.decodeSingularMessageField(value: &v)
262
+ if let v = v {
263
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
264
+ _storage._payload = .ready(v)
265
+ }
266
+ }()
267
+ case 11: try {
268
+ var v: Pulsefield_Protocol_V1_AudioRequest?
269
+ var hadOneofValue = false
270
+ if let current = _storage._payload {
271
+ hadOneofValue = true
272
+ if case .audio(let m) = current {v = m}
273
+ }
274
+ try decoder.decodeSingularMessageField(value: &v)
275
+ if let v = v {
276
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
277
+ _storage._payload = .audio(v)
278
+ }
279
+ }()
280
+ case 12: try {
281
+ var v: Pulsefield_Protocol_V1_ReferenceTimeRequest?
282
+ var hadOneofValue = false
283
+ if let current = _storage._payload {
284
+ hadOneofValue = true
285
+ if case .referenceTime(let m) = current {v = m}
286
+ }
287
+ try decoder.decodeSingularMessageField(value: &v)
288
+ if let v = v {
289
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
290
+ _storage._payload = .referenceTime(v)
291
+ }
292
+ }()
293
+ case 13: try {
294
+ var v: Pulsefield_Protocol_V1_StopSessionRequest?
295
+ var hadOneofValue = false
296
+ if let current = _storage._payload {
297
+ hadOneofValue = true
298
+ if case .stopSession(let m) = current {v = m}
299
+ }
300
+ try decoder.decodeSingularMessageField(value: &v)
301
+ if let v = v {
302
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
303
+ _storage._payload = .stopSession(v)
304
+ }
305
+ }()
306
+ case 19: try {
307
+ var v: Pulsefield_Protocol_V1_MapperStreamBeginEvent?
308
+ var hadOneofValue = false
309
+ if let current = _storage._payload {
310
+ hadOneofValue = true
311
+ if case .mapperStreamBegin(let m) = current {v = m}
312
+ }
313
+ try decoder.decodeSingularMessageField(value: &v)
314
+ if let v = v {
315
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
316
+ _storage._payload = .mapperStreamBegin(v)
317
+ }
318
+ }()
319
+ case 20: try {
320
+ var v: Pulsefield_Protocol_V1_HitObjectTokenEvent?
321
+ var hadOneofValue = false
322
+ if let current = _storage._payload {
323
+ hadOneofValue = true
324
+ if case .hitObjectToken(let m) = current {v = m}
325
+ }
326
+ try decoder.decodeSingularMessageField(value: &v)
327
+ if let v = v {
328
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
329
+ _storage._payload = .hitObjectToken(v)
330
+ }
331
+ }()
332
+ case 21: try {
333
+ var v: Pulsefield_Protocol_V1_ErrorEvent?
334
+ var hadOneofValue = false
335
+ if let current = _storage._payload {
336
+ hadOneofValue = true
337
+ if case .error(let m) = current {v = m}
338
+ }
339
+ try decoder.decodeSingularMessageField(value: &v)
340
+ if let v = v {
341
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
342
+ _storage._payload = .error(v)
343
+ }
344
+ }()
345
+ case 22: try {
346
+ var v: Pulsefield_Protocol_V1_StatusEvent?
347
+ var hadOneofValue = false
348
+ if let current = _storage._payload {
349
+ hadOneofValue = true
350
+ if case .status(let m) = current {v = m}
351
+ }
352
+ try decoder.decodeSingularMessageField(value: &v)
353
+ if let v = v {
354
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
355
+ _storage._payload = .status(v)
356
+ }
357
+ }()
358
+ case 23: try {
359
+ var v: Pulsefield_Protocol_V1_EndOfStreamEvent?
360
+ var hadOneofValue = false
361
+ if let current = _storage._payload {
362
+ hadOneofValue = true
363
+ if case .endOfStream(let m) = current {v = m}
364
+ }
365
+ try decoder.decodeSingularMessageField(value: &v)
366
+ if let v = v {
367
+ if hadOneofValue {try decoder.handleConflictingOneOf()}
368
+ _storage._payload = .endOfStream(v)
369
+ }
370
+ }()
371
+ default: break
372
+ }
634
373
  }
635
374
  }
636
375
  }
637
376
 
638
377
  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
639
- // The use of inline closures is to circumvent an issue where the compiler
640
- // allocates stack space for every if/case branch local when no optimizations
641
- // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
642
- // https://github.com/apple/swift-protobuf/issues/1182
643
- if self.refTimeMs != 0 {
644
- try visitor.visitSingularUInt32Field(value: self.refTimeMs, fieldNumber: 1)
645
- }
646
- if self.localHostTimeSendMs.bitPattern != 0 {
647
- try visitor.visitSingularDoubleField(value: self.localHostTimeSendMs, fieldNumber: 2)
648
- }
649
- try { if let v = self._audioLengthMs {
650
- try visitor.visitSingularUInt32Field(value: v, fieldNumber: 3)
651
- } }()
652
- try unknownFields.traverse(visitor: &visitor)
653
- }
654
-
655
- public static func ==(lhs: Pulsefield_Protocol_V1_ReferenceTimeRequest, rhs: Pulsefield_Protocol_V1_ReferenceTimeRequest) -> Bool {
656
- if lhs.refTimeMs != rhs.refTimeMs {return false}
657
- if lhs.localHostTimeSendMs != rhs.localHostTimeSendMs {return false}
658
- if lhs._audioLengthMs != rhs._audioLengthMs {return false}
659
- if lhs.unknownFields != rhs.unknownFields {return false}
660
- return true
661
- }
662
- }
663
-
664
- nonisolated extension Pulsefield_Protocol_V1_StopSessionRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
665
- public static let protoMessageName: String = _protobuf_package + ".StopSessionRequest"
666
- public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}reason\0")
667
-
668
- public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
669
- while let fieldNumber = try decoder.nextFieldNumber() {
378
+ try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
670
379
  // The use of inline closures is to circumvent an issue where the compiler
671
- // allocates stack space for every case branch when no optimizations are
672
- // enabled. https://github.com/apple/swift-protobuf/issues/1034
673
- switch fieldNumber {
674
- case 1: try { try decoder.decodeSingularStringField(value: &self.reason) }()
675
- default: break
380
+ // allocates stack space for every if/case branch local when no optimizations
381
+ // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
382
+ // https://github.com/apple/swift-protobuf/issues/1182
383
+ if !_storage._sessionID.isEmpty {
384
+ try visitor.visitSingularStringField(value: _storage._sessionID, fieldNumber: 1)
676
385
  }
677
- }
678
- }
679
-
680
- public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
681
- if !self.reason.isEmpty {
682
- try visitor.visitSingularStringField(value: self.reason, fieldNumber: 1)
683
- }
684
- try unknownFields.traverse(visitor: &visitor)
685
- }
686
-
687
- public static func ==(lhs: Pulsefield_Protocol_V1_StopSessionRequest, rhs: Pulsefield_Protocol_V1_StopSessionRequest) -> Bool {
688
- if lhs.reason != rhs.reason {return false}
689
- if lhs.unknownFields != rhs.unknownFields {return false}
690
- return true
691
- }
692
- }
693
-
694
- nonisolated extension Pulsefield_Protocol_V1_HitObjectTokenEvent: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
695
- public static let protoMessageName: String = _protobuf_package + ".HitObjectTokenEvent"
696
- public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}token_id\0\u{3}ms_in_ref_audio\0")
697
-
698
- public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
699
- while let fieldNumber = try decoder.nextFieldNumber() {
700
- // The use of inline closures is to circumvent an issue where the compiler
701
- // allocates stack space for every case branch when no optimizations are
702
- // enabled. https://github.com/apple/swift-protobuf/issues/1034
703
- switch fieldNumber {
704
- case 1: try { try decoder.decodeSingularUInt32Field(value: &self.tokenID) }()
705
- case 2: try { try decoder.decodeSingularUInt32Field(value: &self.msInRefAudio) }()
706
- default: break
386
+ if _storage._sequence != 0 {
387
+ try visitor.visitSingularUInt64Field(value: _storage._sequence, fieldNumber: 2)
707
388
  }
708
- }
709
- }
710
-
711
- public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
712
- if self.tokenID != 0 {
713
- try visitor.visitSingularUInt32Field(value: self.tokenID, fieldNumber: 1)
714
- }
715
- if self.msInRefAudio != 0 {
716
- try visitor.visitSingularUInt32Field(value: self.msInRefAudio, fieldNumber: 2)
717
- }
718
- try unknownFields.traverse(visitor: &visitor)
719
- }
720
-
721
- public static func ==(lhs: Pulsefield_Protocol_V1_HitObjectTokenEvent, rhs: Pulsefield_Protocol_V1_HitObjectTokenEvent) -> Bool {
722
- if lhs.tokenID != rhs.tokenID {return false}
723
- if lhs.msInRefAudio != rhs.msInRefAudio {return false}
724
- if lhs.unknownFields != rhs.unknownFields {return false}
725
- return true
726
- }
727
- }
728
-
729
- nonisolated extension Pulsefield_Protocol_V1_ErrorEvent: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
730
- public static let protoMessageName: String = _protobuf_package + ".ErrorEvent"
731
- public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}code\0\u{1}message\0")
732
-
733
- public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
734
- while let fieldNumber = try decoder.nextFieldNumber() {
735
- // The use of inline closures is to circumvent an issue where the compiler
736
- // allocates stack space for every case branch when no optimizations are
737
- // enabled. https://github.com/apple/swift-protobuf/issues/1034
738
- switch fieldNumber {
739
- case 1: try { try decoder.decodeSingularStringField(value: &self.code) }()
740
- case 2: try { try decoder.decodeSingularStringField(value: &self.message) }()
741
- default: break
389
+ if _storage._sentAtUnixMs != 0 {
390
+ try visitor.visitSingularInt64Field(value: _storage._sentAtUnixMs, fieldNumber: 3)
391
+ }
392
+ if !_storage._sourceNodeID.isEmpty {
393
+ try visitor.visitSingularStringField(value: _storage._sourceNodeID, fieldNumber: 4)
394
+ }
395
+ if !_storage._targetNodeID.isEmpty {
396
+ try visitor.visitSingularStringField(value: _storage._targetNodeID, fieldNumber: 5)
397
+ }
398
+ if !_storage._messageID.isEmpty {
399
+ try visitor.visitSingularStringField(value: _storage._messageID, fieldNumber: 6)
400
+ }
401
+ if !_storage._correlationID.isEmpty {
402
+ try visitor.visitSingularStringField(value: _storage._correlationID, fieldNumber: 7)
403
+ }
404
+ switch _storage._payload {
405
+ case .nodeHello?: try {
406
+ guard case .nodeHello(let v)? = _storage._payload else { preconditionFailure() }
407
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 8)
408
+ }()
409
+ case .ready?: try {
410
+ guard case .ready(let v)? = _storage._payload else { preconditionFailure() }
411
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 10)
412
+ }()
413
+ case .audio?: try {
414
+ guard case .audio(let v)? = _storage._payload else { preconditionFailure() }
415
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 11)
416
+ }()
417
+ case .referenceTime?: try {
418
+ guard case .referenceTime(let v)? = _storage._payload else { preconditionFailure() }
419
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 12)
420
+ }()
421
+ case .stopSession?: try {
422
+ guard case .stopSession(let v)? = _storage._payload else { preconditionFailure() }
423
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 13)
424
+ }()
425
+ case .mapperStreamBegin?: try {
426
+ guard case .mapperStreamBegin(let v)? = _storage._payload else { preconditionFailure() }
427
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 19)
428
+ }()
429
+ case .hitObjectToken?: try {
430
+ guard case .hitObjectToken(let v)? = _storage._payload else { preconditionFailure() }
431
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 20)
432
+ }()
433
+ case .error?: try {
434
+ guard case .error(let v)? = _storage._payload else { preconditionFailure() }
435
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 21)
436
+ }()
437
+ case .status?: try {
438
+ guard case .status(let v)? = _storage._payload else { preconditionFailure() }
439
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 22)
440
+ }()
441
+ case .endOfStream?: try {
442
+ guard case .endOfStream(let v)? = _storage._payload else { preconditionFailure() }
443
+ try visitor.visitSingularMessageField(value: v, fieldNumber: 23)
444
+ }()
445
+ case nil: break
742
446
  }
743
- }
744
- }
745
-
746
- public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
747
- if !self.code.isEmpty {
748
- try visitor.visitSingularStringField(value: self.code, fieldNumber: 1)
749
- }
750
- if !self.message.isEmpty {
751
- try visitor.visitSingularStringField(value: self.message, fieldNumber: 2)
752
447
  }
753
448
  try unknownFields.traverse(visitor: &visitor)
754
449
  }
755
450
 
756
- public static func ==(lhs: Pulsefield_Protocol_V1_ErrorEvent, rhs: Pulsefield_Protocol_V1_ErrorEvent) -> Bool {
757
- if lhs.code != rhs.code {return false}
758
- if lhs.message != rhs.message {return false}
759
- if lhs.unknownFields != rhs.unknownFields {return false}
760
- return true
761
- }
762
- }
763
-
764
- nonisolated extension Pulsefield_Protocol_V1_StatusEvent: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
765
- public static let protoMessageName: String = _protobuf_package + ".StatusEvent"
766
- public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}status\0\u{1}message\0\u{3}ref_time_ms\0\u{3}local_host_time_ms\0")
767
-
768
- public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
769
- while let fieldNumber = try decoder.nextFieldNumber() {
770
- // The use of inline closures is to circumvent an issue where the compiler
771
- // allocates stack space for every case branch when no optimizations are
772
- // enabled. https://github.com/apple/swift-protobuf/issues/1034
773
- switch fieldNumber {
774
- case 1: try { try decoder.decodeSingularEnumField(value: &self.status) }()
775
- case 2: try { try decoder.decodeSingularStringField(value: &self.message) }()
776
- case 3: try { try decoder.decodeSingularUInt32Field(value: &self.refTimeMs) }()
777
- case 4: try { try decoder.decodeSingularDoubleField(value: &self.localHostTimeMs) }()
778
- default: break
451
+ public static func ==(lhs: Pulsefield_Protocol_V1_Envelope, rhs: Pulsefield_Protocol_V1_Envelope) -> Bool {
452
+ if lhs._storage !== rhs._storage {
453
+ let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in
454
+ let _storage = _args.0
455
+ let rhs_storage = _args.1
456
+ if _storage._sessionID != rhs_storage._sessionID {return false}
457
+ if _storage._sequence != rhs_storage._sequence {return false}
458
+ if _storage._sentAtUnixMs != rhs_storage._sentAtUnixMs {return false}
459
+ if _storage._sourceNodeID != rhs_storage._sourceNodeID {return false}
460
+ if _storage._targetNodeID != rhs_storage._targetNodeID {return false}
461
+ if _storage._messageID != rhs_storage._messageID {return false}
462
+ if _storage._correlationID != rhs_storage._correlationID {return false}
463
+ if _storage._payload != rhs_storage._payload {return false}
464
+ return true
779
465
  }
466
+ if !storagesAreEqual {return false}
780
467
  }
781
- }
782
-
783
- public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
784
- if self.status != .unspecified {
785
- try visitor.visitSingularEnumField(value: self.status, fieldNumber: 1)
786
- }
787
- if !self.message.isEmpty {
788
- try visitor.visitSingularStringField(value: self.message, fieldNumber: 2)
789
- }
790
- if self.refTimeMs != 0 {
791
- try visitor.visitSingularUInt32Field(value: self.refTimeMs, fieldNumber: 3)
792
- }
793
- if self.localHostTimeMs.bitPattern != 0 {
794
- try visitor.visitSingularDoubleField(value: self.localHostTimeMs, fieldNumber: 4)
795
- }
796
- try unknownFields.traverse(visitor: &visitor)
797
- }
798
-
799
- public static func ==(lhs: Pulsefield_Protocol_V1_StatusEvent, rhs: Pulsefield_Protocol_V1_StatusEvent) -> Bool {
800
- if lhs.status != rhs.status {return false}
801
- if lhs.message != rhs.message {return false}
802
- if lhs.refTimeMs != rhs.refTimeMs {return false}
803
- if lhs.localHostTimeMs != rhs.localHostTimeMs {return false}
804
468
  if lhs.unknownFields != rhs.unknownFields {return false}
805
469
  return true
806
470
  }