BinaryEncodingOptions.swift 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. // Sources/SwiftProtobuf/BinaryEncodingOptions.swift - Binary encoding options
  2. //
  3. // Copyright (c) 2014 - 2023 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 encoding options
  12. ///
  13. // -----------------------------------------------------------------------------
  14. /// Options for binary encoding.
  15. public struct BinaryEncodingOptions: Sendable {
  16. /// Whether to use deterministic ordering when serializing.
  17. ///
  18. /// Note that the deterministic serialization is NOT canonical across languages.
  19. /// It is NOT guaranteed to remain stable over time. It is unstable across
  20. /// different builds with schema changes due to unknown fields. Users who need
  21. /// canonical serialization (e.g., persistent storage in a canonical form,
  22. /// fingerprinting, etc.) should define their own canonicalization specification
  23. /// and implement their own serializer rather than relying on this API.
  24. ///
  25. /// If deterministic serialization is requested, map entries will be sorted
  26. /// by keys in lexicographical order. This is an implementation detail
  27. /// and subject to change.
  28. public var useDeterministicOrdering: Bool = false
  29. public init() {}
  30. }