BinaryDecodingOptions.swift 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Sources/SwiftProtobuf/BinaryDecodingOptions.swift - Binary decoding options
  2. //
  3. // Copyright (c) 2014 - 2017 Apple Inc. and the project authors
  4. // Licensed under Apache License v2.0 with Runtime Library Exception
  5. //
  6. // See LICENSE.txt for license information:
  7. // https://github.com/apple/swift-protobuf/blob/main/LICENSE.txt
  8. //
  9. // -----------------------------------------------------------------------------
  10. ///
  11. /// Binary decoding options
  12. ///
  13. // -----------------------------------------------------------------------------
  14. /// Options for binary decoding.
  15. public struct BinaryDecodingOptions: Sendable {
  16. /// The maximum nesting of message with messages. The default is 100.
  17. ///
  18. /// To prevent corrupt or malicious messages from causing stack overflows,
  19. /// this controls how deep messages can be nested within other messages
  20. /// while parsing.
  21. public var messageDepthLimit: Int = 100
  22. /// Discard unknown fields while parsing. The default is false, so parsering
  23. /// does not discard unknown fields.
  24. ///
  25. /// The Protobuf binary format allows unknown fields to be still parsed
  26. /// so the schema can be expanded without requiring all readers to be updated.
  27. /// This works in part by having any unknown fields preserved so they can
  28. /// be relayed on without loss. For a while the proto3 syntax definition
  29. /// called for unknown fields to be dropped, but that lead to problems in
  30. /// some case. The default is to follow the spec and keep them, but setting
  31. /// this option to `true` allows a developer to strip them during a parse
  32. /// in case they have a specific need to drop the unknown fields from the
  33. /// object graph being created.
  34. public var discardUnknownFields: Bool = false
  35. public init() {}
  36. }