any.pb.swift 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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: google/protobuf/any.proto
  7. //
  8. // For information on using the generated types, please see the documentation:
  9. // https://github.com/apple/swift-protobuf/
  10. // Protocol Buffers - Google's data interchange format
  11. // Copyright 2008 Google Inc. All rights reserved.
  12. // https://developers.google.com/protocol-buffers/
  13. //
  14. // Redistribution and use in source and binary forms, with or without
  15. // modification, are permitted provided that the following conditions are
  16. // met:
  17. //
  18. // * Redistributions of source code must retain the above copyright
  19. // notice, this list of conditions and the following disclaimer.
  20. // * Redistributions in binary form must reproduce the above
  21. // copyright notice, this list of conditions and the following disclaimer
  22. // in the documentation and/or other materials provided with the
  23. // distribution.
  24. // * Neither the name of Google Inc. nor the names of its
  25. // contributors may be used to endorse or promote products derived from
  26. // this software without specific prior written permission.
  27. //
  28. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  29. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  30. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  31. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  32. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  33. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  34. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  35. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  36. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  37. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  38. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  39. import Foundation
  40. // 'import SwiftProtobuf' suppressed, this proto file is meant to be bundled in the runtime.
  41. // If the compiler emits an error on this type, it is because this file
  42. // was generated by a version of the `protoc` Swift plug-in that is
  43. // incompatible with the version of SwiftProtobuf to which you are linking.
  44. // Please ensure that you are building against the same version of the API
  45. // that was used to generate this file.
  46. fileprivate struct _GeneratedWithProtocGenSwiftVersion: ProtobufAPIVersionCheck {
  47. struct _2: ProtobufAPIVersion_2 {}
  48. typealias Version = _2
  49. }
  50. /// `Any` contains an arbitrary serialized protocol buffer message along with a
  51. /// URL that describes the type of the serialized message.
  52. ///
  53. /// Protobuf library provides support to pack/unpack Any values in the form
  54. /// of utility functions or additional generated methods of the Any type.
  55. ///
  56. /// Example 1: Pack and unpack a message in C++.
  57. ///
  58. /// Foo foo = ...;
  59. /// Any any;
  60. /// any.PackFrom(foo);
  61. /// ...
  62. /// if (any.UnpackTo(&foo)) {
  63. /// ...
  64. /// }
  65. ///
  66. /// Example 2: Pack and unpack a message in Java.
  67. ///
  68. /// Foo foo = ...;
  69. /// Any any = Any.pack(foo);
  70. /// ...
  71. /// if (any.is(Foo.class)) {
  72. /// foo = any.unpack(Foo.class);
  73. /// }
  74. /// // or ...
  75. /// if (any.isSameTypeAs(Foo.getDefaultInstance())) {
  76. /// foo = any.unpack(Foo.getDefaultInstance());
  77. /// }
  78. ///
  79. /// Example 3: Pack and unpack a message in Python.
  80. ///
  81. /// foo = Foo(...)
  82. /// any = Any()
  83. /// any.Pack(foo)
  84. /// ...
  85. /// if any.Is(Foo.DESCRIPTOR):
  86. /// any.Unpack(foo)
  87. /// ...
  88. ///
  89. /// Example 4: Pack and unpack a message in Go
  90. ///
  91. /// foo := &pb.Foo{...}
  92. /// any, err := anypb.New(foo)
  93. /// if err != nil {
  94. /// ...
  95. /// }
  96. /// ...
  97. /// foo := &pb.Foo{}
  98. /// if err := any.UnmarshalTo(foo); err != nil {
  99. /// ...
  100. /// }
  101. ///
  102. /// The pack methods provided by protobuf library will by default use
  103. /// 'type.googleapis.com/full.type.name' as the type URL and the unpack
  104. /// methods only use the fully qualified type name after the last '/'
  105. /// in the type URL, for example "foo.bar.com/x/y.z" will yield type
  106. /// name "y.z".
  107. ///
  108. /// JSON
  109. /// ====
  110. /// The JSON representation of an `Any` value uses the regular
  111. /// representation of the deserialized, embedded message, with an
  112. /// additional field `@type` which contains the type URL. Example:
  113. ///
  114. /// package google.profile;
  115. /// message Person {
  116. /// string first_name = 1;
  117. /// string last_name = 2;
  118. /// }
  119. ///
  120. /// {
  121. /// "@type": "type.googleapis.com/google.profile.Person",
  122. /// "firstName": <string>,
  123. /// "lastName": <string>
  124. /// }
  125. ///
  126. /// If the embedded message type is well-known and has a custom JSON
  127. /// representation, that representation will be embedded adding a field
  128. /// `value` which holds the custom JSON in addition to the `@type`
  129. /// field. Example (for message [google.protobuf.Duration][]):
  130. ///
  131. /// {
  132. /// "@type": "type.googleapis.com/google.protobuf.Duration",
  133. /// "value": "1.212s"
  134. /// }
  135. struct Google_Protobuf_Any: @unchecked Sendable {
  136. // SwiftProtobuf.Message conformance is added in an extension below. See the
  137. // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  138. // methods supported on all messages.
  139. /// A URL/resource name that uniquely identifies the type of the serialized
  140. /// protocol buffer message. This string must contain at least
  141. /// one "/" character. The last segment of the URL's path must represent
  142. /// the fully qualified name of the type (as in
  143. /// `path/google.protobuf.Duration`). The name should be in a canonical form
  144. /// (e.g., leading "." is not accepted).
  145. ///
  146. /// In practice, teams usually precompile into the binary all types that they
  147. /// expect it to use in the context of Any. However, for URLs which use the
  148. /// scheme `http`, `https`, or no scheme, one can optionally set up a type
  149. /// server that maps type URLs to message definitions as follows:
  150. ///
  151. /// * If no scheme is provided, `https` is assumed.
  152. /// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
  153. /// value in binary format, or produce an error.
  154. /// * Applications are allowed to cache lookup results based on the
  155. /// URL, or have them precompiled into a binary to avoid any
  156. /// lookup. Therefore, binary compatibility needs to be preserved
  157. /// on changes to types. (Use versioned type names to manage
  158. /// breaking changes.)
  159. ///
  160. /// Note: this functionality is not currently available in the official
  161. /// protobuf release, and it is not used for type URLs beginning with
  162. /// type.googleapis.com. As of May 2023, there are no widely used type server
  163. /// implementations and no plans to implement one.
  164. ///
  165. /// Schemes other than `http`, `https` (or the empty scheme) might be
  166. /// used with implementation specific semantics.
  167. var typeURL: String {
  168. get {_storage._typeURL}
  169. set {_uniqueStorage()._typeURL = newValue}
  170. }
  171. /// Must be a valid serialized protocol buffer of the above specified type.
  172. var value: Data {
  173. get {_storage._value}
  174. set {_uniqueStorage()._value = newValue}
  175. }
  176. var unknownFields = UnknownStorage()
  177. init() {}
  178. internal var _storage = _StorageClass.defaultInstance
  179. }
  180. // MARK: - Code below here is support for the SwiftProtobuf runtime.
  181. fileprivate let _protobuf_package = "google.protobuf"
  182. extension Google_Protobuf_Any: Message, _MessageImplementationBase, _ProtoNameProviding {
  183. static let protoMessageName: String = _protobuf_package + ".Any"
  184. static let _protobuf_nameMap = _NameMap(bytecode: "\0\u{3}type_url\0\u{1}value\0")
  185. typealias _StorageClass = AnyMessageStorage
  186. internal mutating func _uniqueStorage() -> _StorageClass {
  187. if !isKnownUniquelyReferenced(&_storage) {
  188. _storage = _StorageClass(copying: _storage)
  189. }
  190. return _storage
  191. }
  192. mutating func decodeMessage<D: Decoder>(decoder: inout D) throws {
  193. _ = _uniqueStorage()
  194. try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
  195. while let fieldNumber = try decoder.nextFieldNumber() {
  196. // The use of inline closures is to circumvent an issue where the compiler
  197. // allocates stack space for every case branch when no optimizations are
  198. // enabled. https://github.com/apple/swift-protobuf/issues/1034
  199. switch fieldNumber {
  200. case 1: try { try decoder.decodeSingularStringField(value: &_storage._typeURL) }()
  201. case 2: try { try decoder.decodeSingularBytesField(value: &_storage._value) }()
  202. default: break
  203. }
  204. }
  205. }
  206. }
  207. func traverse<V: Visitor>(visitor: inout V) throws {
  208. try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
  209. try _storage.preTraverse()
  210. if !_storage._typeURL.isEmpty {
  211. try visitor.visitSingularStringField(value: _storage._typeURL, fieldNumber: 1)
  212. }
  213. if !_storage._value.isEmpty {
  214. try visitor.visitSingularBytesField(value: _storage._value, fieldNumber: 2)
  215. }
  216. }
  217. try unknownFields.traverse(visitor: &visitor)
  218. }
  219. static func ==(lhs: Google_Protobuf_Any, rhs: Google_Protobuf_Any) -> Bool {
  220. if lhs._storage !== rhs._storage {
  221. let storagesAreEqual: Bool = lhs._storage.isEqualTo(other: rhs._storage)
  222. if !storagesAreEqual {return false}
  223. }
  224. if lhs.unknownFields != rhs.unknownFields {return false}
  225. return true
  226. }
  227. }