SomeProtoWithBytes.pb.swift 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // DO NOT EDIT.
  2. // swift-format-ignore-file
  3. // swiftlint:disable all
  4. //
  5. // Generated by the Swift generator plugin for the protocol buffer compiler.
  6. // Source: SomeProtoWithBytes.proto
  7. //
  8. // For information on using the generated types, please see the documentation:
  9. // https://github.com/apple/swift-protobuf/
  10. public import Foundation
  11. public import SwiftProtobuf
  12. // If the compiler emits an error on this type, it is because this file
  13. // was generated by a version of the `protoc` Swift plug-in that is
  14. // incompatible with the version of SwiftProtobuf to which you are linking.
  15. // Please ensure that you are building against the same version of the API
  16. // that was used to generate this file.
  17. fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
  18. struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
  19. typealias Version = _2
  20. }
  21. public struct SomeProtoWithBytes: Sendable {
  22. // SwiftProtobuf.Message conformance is added in an extension below. See the
  23. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  24. // methods supported on all messages.
  25. public var someBytes: Data {
  26. get {_someBytes ?? Data()}
  27. set {_someBytes = newValue}
  28. }
  29. /// Returns true if `someBytes` has been explicitly set.
  30. public var hasSomeBytes: Bool {self._someBytes != nil}
  31. /// Clears the value of `someBytes`. Subsequent reads from it will return its default value.
  32. public mutating func clearSomeBytes() {self._someBytes = nil}
  33. public var extStr: String {
  34. get {_extStr ?? String()}
  35. set {_extStr = newValue}
  36. }
  37. /// Returns true if `extStr` has been explicitly set.
  38. public var hasExtStr: Bool {self._extStr != nil}
  39. /// Clears the value of `extStr`. Subsequent reads from it will return its default value.
  40. public mutating func clearExtStr() {self._extStr = nil}
  41. public var unknownFields = SwiftProtobuf.UnknownStorage()
  42. public init() {}
  43. fileprivate var _someBytes: Data? = nil
  44. fileprivate var _extStr: String? = nil
  45. }
  46. // MARK: - Code below here is support for the SwiftProtobuf runtime.
  47. extension SomeProtoWithBytes: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  48. public static let protoMessageName: String = "SomeProtoWithBytes"
  49. public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{2}\u{2}someBytes\0\u{4}b\u{1}ext_str\0")
  50. public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
  51. while let fieldNumber = try decoder.nextFieldNumber() {
  52. // The use of inline closures is to circumvent an issue where the compiler
  53. // allocates stack space for every case branch when no optimizations are
  54. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  55. switch fieldNumber {
  56. case 2: try { try decoder.decodeSingularBytesField(value: &self._someBytes) }()
  57. case 100: try { try decoder.decodeSingularStringField(value: &self._extStr) }()
  58. default: break
  59. }
  60. }
  61. }
  62. public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
  63. // The use of inline closures is to circumvent an issue where the compiler
  64. // allocates stack space for every if/case branch local when no optimizations
  65. // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
  66. // https://github.com/apple/swift-protobuf/issues/1182
  67. try { if let v = self._someBytes {
  68. try visitor.visitSingularBytesField(value: v, fieldNumber: 2)
  69. } }()
  70. try { if let v = self._extStr {
  71. try visitor.visitSingularStringField(value: v, fieldNumber: 100)
  72. } }()
  73. try unknownFields.traverse(visitor: &visitor)
  74. }
  75. public static func ==(lhs: SomeProtoWithBytes, rhs: SomeProtoWithBytes) -> Bool {
  76. if lhs._someBytes != rhs._someBytes {return false}
  77. if lhs._extStr != rhs._extStr {return false}
  78. if lhs.unknownFields != rhs.unknownFields {return false}
  79. return true
  80. }
  81. }