Skip to content

Commit

Permalink
Add Sendable to more places that folks might want it.
Browse files Browse the repository at this point in the history
Ensure all the Decoding/Encoding Options types are marked Sendable.

There are still some places with TOOD around `Sendable`, but `Data` lack of support
in 5.6 is making this a little complex to sort out.
  • Loading branch information
thomasvl committed Aug 16, 2023
1 parent d9e26c9 commit 0556b47
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Sources/SwiftProtobuf/BinaryDecodingOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// -----------------------------------------------------------------------------

/// Options for binary decoding.
public struct BinaryDecodingOptions {
public struct BinaryDecodingOptions: Sendable {
/// The maximum nesting of message with messages. The default is 100.
///
/// To prevent corrupt or malicious messages from causing stack overflows,
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftProtobuf/ExtensionMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/// This is a protocol so that developers can build their own
/// extension handling if they need something more complex than the
/// standard `SimpleExtensionMap` implementation.
public protocol ExtensionMap {
public protocol ExtensionMap: Sendable {
/// Returns the extension object describing an extension or nil
subscript(messageType: Message.Type, fieldNumber: Int) -> AnyMessageExtension? { get }

Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftProtobuf/JSONDecodingOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// -----------------------------------------------------------------------------

/// Options for JSONDecoding.
public struct JSONDecodingOptions {
public struct JSONDecodingOptions: Sendable {
/// The maximum nesting of message with messages. The default is 100.
///
/// To prevent corrupt or malicious messages from causing stack overflows,
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftProtobuf/JSONEncodingOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// -----------------------------------------------------------------------------

/// Options for JSONEncoding.
public struct JSONEncodingOptions {
public struct JSONEncodingOptions: Sendable {

/// Always prints int64s values as numbers.
/// By default, they are printed as strings as per proto3 JSON mapping rules.
Expand Down
6 changes: 2 additions & 4 deletions Sources/SwiftProtobuf/MessageExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
///
// -----------------------------------------------------------------------------

// TODO: `AnyMessageExtension` should require `Sendable` but we cannot do so yet without possibly breaking compatibility.

/// Type-erased MessageExtension field implementation.
public protocol AnyMessageExtension {
public protocol AnyMessageExtension: Sendable {
var fieldNumber: Int { get }
var fieldName: String { get }
var messageType: Message.Type { get }
Expand All @@ -28,7 +26,7 @@ public protocol AnyMessageExtension {
/// A "Message Extension" relates a particular extension field to
/// a particular message. The generic constraints allow
/// compile-time compatibility checks.
public class MessageExtension<FieldType: ExtensionField, MessageType: Message>: AnyMessageExtension {
public final class MessageExtension<FieldType: ExtensionField, MessageType: Message>: AnyMessageExtension {
public let fieldNumber: Int
public let fieldName: String
public let messageType: Message.Type
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftProtobuf/TextFormatDecodingOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// -----------------------------------------------------------------------------

/// Options for TextFormatDecoding.
public struct TextFormatDecodingOptions {
public struct TextFormatDecodingOptions: Sendable {
/// The maximum nesting of message with messages. The default is 100.
///
/// To prevent corrupt or malicious messages from causing stack overflows,
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftProtobuf/TextFormatEncodingOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// -----------------------------------------------------------------------------

/// Options for TextFormatEncoding.
public struct TextFormatEncodingOptions {
public struct TextFormatEncodingOptions: Sendable {

/// Default: Do print unknown fields using numeric notation
public var printUnknownFields: Bool = true
Expand Down

0 comments on commit 0556b47

Please sign in to comment.