Skip to content

Commit 6957112

Browse files
authored
Merge branch 'main' into rfc-9651/documentation-update
2 parents 19df112 + 1a14678 commit 6957112

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

Sources/RawStructuredFieldValues/ComponentTypes.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ extension BareItem {
9494
self = .bool(b)
9595

9696
case .integer(let i):
97-
self = .integer(i)
97+
self = .integer(Int(i))
9898

9999
case .decimal(let d):
100100
self = .decimal(d)
@@ -126,7 +126,7 @@ public enum RFC9651BareItem: Sendable {
126126
case bool(Bool)
127127

128128
/// An integer item.
129-
case integer(Int)
129+
case integer(Int64)
130130

131131
/// A decimal item.
132132
case decimal(PseudoDecimal)
@@ -142,7 +142,7 @@ public enum RFC9651BareItem: Sendable {
142142
case token(String)
143143

144144
/// A date item.
145-
case date(Int)
145+
case date(Int64)
146146

147147
/// A display string item.
148148
case displayString(String)
@@ -155,7 +155,7 @@ extension RFC9651BareItem: ExpressibleByBooleanLiteral {
155155
}
156156

157157
extension RFC9651BareItem: ExpressibleByIntegerLiteral {
158-
public init(integerLiteral value: Int) {
158+
public init(integerLiteral value: Int64) {
159159
self = .integer(value)
160160
}
161161
}
@@ -184,7 +184,7 @@ extension RFC9651BareItem {
184184
self = .bool(b)
185185

186186
case .integer(let i):
187-
self = .integer(i)
187+
self = .integer(Int64(i))
188188

189189
case .decimal(let d):
190190
self = .decimal(d)

Sources/RawStructuredFieldValues/FieldParser.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ extension StructuredFieldValueParser {
232232
}
233233

234234
private mutating func _parseAnIntegerOrDecimal(isDate: Bool) throws -> RFC9651BareItem {
235-
var sign = 1
235+
var sign = Int64(1)
236236
var type = IntegerOrDecimal.integer
237237

238238
if let first = self.underlyingData.first, first == asciiDash {
@@ -304,7 +304,7 @@ extension StructuredFieldValueParser {
304304
case .integer:
305305
// This intermediate string is sad, we should rewrite this manually to avoid it.
306306
// This force-unwrap is safe, as we have validated that all characters are ascii digits.
307-
let baseInt = Int(String(decoding: integerBytes, as: UTF8.self), radix: 10)!
307+
let baseInt = Int64(String(decoding: integerBytes, as: UTF8.self), radix: 10)!
308308
let resultingInt = baseInt * sign
309309

310310
if isDate {

Sources/StructuredFieldValues/Encoder/StructuredFieldValueEncoder.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ extension _StructuredFieldEncoder: SingleValueEncodingContainer {
313313
}
314314

315315
func encode(_ data: Date) throws {
316-
let date = Int(data.timeIntervalSince1970)
316+
let date = Int64(data.timeIntervalSince1970)
317317
try self.currentStackEntry.storage.insertBareItem(.date(date))
318318
}
319319

@@ -371,7 +371,7 @@ extension _StructuredFieldEncoder: SingleValueEncodingContainer {
371371
}
372372

373373
private func _encodeFixedWidthInteger<T: FixedWidthInteger>(_ value: T) throws {
374-
guard let base = Int(exactly: value) else {
374+
guard let base = Int64(exactly: value) else {
375375
throw StructuredHeaderError.integerOutOfRange
376376
}
377377
try self.currentStackEntry.storage.insertBareItem(.integer(base))
@@ -483,7 +483,7 @@ extension _StructuredFieldEncoder {
483483
}
484484

485485
func append(_ value: Date) throws {
486-
let date = Int(value.timeIntervalSince1970)
486+
let date = Int64(value.timeIntervalSince1970)
487487
try self.currentStackEntry.storage.appendBareItem(.date(date))
488488
}
489489

@@ -562,7 +562,7 @@ extension _StructuredFieldEncoder {
562562
}
563563

564564
private func _appendFixedWidthInteger<T: FixedWidthInteger>(_ value: T) throws {
565-
guard let base = Int(exactly: value) else {
565+
guard let base = Int64(exactly: value) else {
566566
throw StructuredHeaderError.integerOutOfRange
567567
}
568568
try self.currentStackEntry.storage.appendBareItem(.integer(base))
@@ -667,7 +667,7 @@ extension _StructuredFieldEncoder {
667667

668668
func encode(_ value: Date, forKey key: String) throws {
669669
let key = self.sanitizeKey(key)
670-
let date = Int(value.timeIntervalSince1970)
670+
let date = Int64(value.timeIntervalSince1970)
671671
try self.currentStackEntry.storage.insertBareItem(.date(date), atKey: key)
672672
}
673673

@@ -789,7 +789,7 @@ extension _StructuredFieldEncoder {
789789
}
790790

791791
private func _encodeFixedWidthInteger<T: FixedWidthInteger>(_ value: T, forKey key: String) throws {
792-
guard let base = Int(exactly: value) else {
792+
guard let base = Int64(exactly: value) else {
793793
throw StructuredHeaderError.integerOutOfRange
794794
}
795795
try self.currentStackEntry.storage.insertBareItem(.integer(base), atKey: key)

Tests/StructuredFieldValuesTests/Fixtures.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ struct StructuredHeaderTestFixture: Decodable {
119119
enum JSONSchema: Decodable {
120120
case dictionary([String: JSONSchema])
121121
case array([JSONSchema])
122-
case integer(Int)
122+
case integer(Int64)
123123
case double(Double)
124124
case string(String)
125125
case bool(Bool)
@@ -130,7 +130,7 @@ enum JSONSchema: Decodable {
130130
self = .string(value)
131131
} else if let bool = try? container.decode(Bool.self) {
132132
self = .bool(bool)
133-
} else if let value = try? container.decode(Int.self) {
133+
} else if let value = try? container.decode(Int64.self) {
134134
self = .integer(value)
135135
} else if let value = try? container.decode(Double.self) {
136136
self = .double(value)

0 commit comments

Comments
 (0)