Skip to content

Commit aeb9c92

Browse files
PeterAdams-ALukasa
andauthored
More Sendability annotiations (#72)
Motivation: Completing annotations helps with coverage for consuming projects. Modifications: Mark more things and Sendable or not. Result: Consuming libraries more likely to get correct usage. Co-authored-by: Cory Benfield <lukasa@apple.com>
1 parent 9969712 commit aeb9c92

File tree

5 files changed

+36
-4
lines changed

5 files changed

+36
-4
lines changed

Sources/SwiftASN1/ASN1.swift

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
16+
@available(*, unavailable)
17+
extension ASN1: Sendable { }
18+
1519
public enum ASN1 {}
1620

1721
// MARK: - EncodingRules
1822
extension ASN1 {
1923
@usableFromInline
20-
enum EncodingRules {
24+
enum EncodingRules: Sendable {
2125
case basic
2226

2327
case distinguished
@@ -124,7 +128,7 @@ extension ASN1.ParserNode {
124128

125129
extension ASN1 {
126130
@usableFromInline
127-
struct ParseResult {
131+
struct ParseResult: Sendable {
128132
@inlinable
129133
static var _maximumNodeDepth: Int { 50 }
130134

@@ -303,6 +307,12 @@ extension ASN1 {
303307
}
304308
}
305309

310+
@available(*, unavailable)
311+
extension ASN1.LazySetOfSequence: Sendable {}
312+
313+
@available(*, unavailable)
314+
extension ASN1.LazySetOfSequence.Iterator: Sendable {}
315+
306316
// MARK: - NodeCollection
307317
/// Represents a collection of ASN.1 nodes contained in a constructed ASN.1 node.
308318
///
@@ -333,7 +343,7 @@ extension ASN1NodeCollection: Sendable {}
333343

334344
extension ASN1NodeCollection: Sequence {
335345
/// An iterator of ASN.1 nodes that are children of a specific constructed node.
336-
public struct Iterator: IteratorProtocol {
346+
public struct Iterator: IteratorProtocol, Sendable {
337347
@usableFromInline
338348
var _nodes: ArraySlice<ASN1.ParserNode>
339349

@@ -427,7 +437,7 @@ extension ASN1Node {
427437

428438
extension ArraySlice where Element == UInt8 {
429439
@usableFromInline
430-
enum ASN1Length {
440+
enum ASN1Length: Sendable {
431441
case indefinite
432442
case definite(_: UInt)
433443
}

Sources/SwiftASN1/BER.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
/// for BER encoding and decoding.
1717
public enum BER {}
1818

19+
@available(*, unavailable)
20+
extension BER: Sendable {}
21+
1922
// MARK: - Parser Node
2023
extension BER {
2124
@usableFromInline

Sources/SwiftASN1/Basic ASN1 Types/ObjectIdentifier.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,18 @@ extension ASN1ObjectIdentifier: CustomStringConvertible {
217217
}
218218
}
219219

220+
@available(*, unavailable)
221+
extension ASN1ObjectIdentifier.NamedCurves: Sendable {}
222+
223+
@available(*, unavailable)
224+
extension ASN1ObjectIdentifier.AlgorithmIdentifier: Sendable {}
225+
226+
@available(*, unavailable)
227+
extension ASN1ObjectIdentifier.NameAttributes: Sendable {}
228+
229+
@available(*, unavailable)
230+
extension ASN1ObjectIdentifier.OCSP: Sendable {}
231+
220232
extension ASN1ObjectIdentifier {
221233
/// Represents a namespace for OIDs that identify named Elliptic Curves.
222234
///

Sources/SwiftASN1/Basic ASN1 Types/TimeUtilities.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
16+
@available(*, unavailable)
17+
extension TimeUtilities: Sendable {}
18+
1519
@usableFromInline
1620
enum TimeUtilities {
1721
@inlinable

Sources/SwiftASN1/DER.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
/// for DER encoding and decoding.
1717
public enum DER {}
1818

19+
@available(*, unavailable)
20+
extension DER: Sendable {}
21+
1922
// MARK: - Parser Node
2023
extension DER {
2124
@usableFromInline

0 commit comments

Comments
 (0)