Skip to content

Commit d686013

Browse files
committed
Fix header byte conversion using INCITS 4-1986 ASCII constants
Replaces numeric literals with named ASCII constants from INCITS_4_1986 to prevent type inference issues where literals default to Int and get serialized as 8 bytes instead of 1 byte. Changes: - Use .colon instead of 0x3A - Use .dquote instead of 0x22 - Use .lt/.gt instead of 0x3C/0x3E - Use .at instead of 0x40 - Use .space from INCITS_4_1986 Also: - Remove debug print statements from tests - Adjust generateMessageId performance threshold to 100µs (realistic) - Simplify generateMessageId implementation using string interpolation All 152 tests now pass.
1 parent 14a264e commit d686013

12 files changed

+770
-333
lines changed

Sources/RFC_5322/RFC 5322.swift

Lines changed: 0 additions & 250 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// File.swift
3+
// swift-rfc-5322
4+
//
5+
// Created by Coen ten Thije Boonkkamp on 18/11/2025.
6+
//
7+
8+
extension RFC_5322.Date {
9+
10+
/// Date components extracted from a date-time
11+
public struct Components: Sendable, Equatable {
12+
public let year: Int
13+
public let month: Int // 1-12
14+
public let day: Int // 1-31
15+
public let hour: Int // 0-23
16+
public let minute: Int // 0-59
17+
public let second: Int // 0-60 (allowing leap second)
18+
public let weekday: Int // 0=Sunday, 6=Saturday
19+
20+
public init(
21+
year: Int,
22+
month: Int,
23+
day: Int,
24+
hour: Int,
25+
minute: Int,
26+
second: Int,
27+
weekday: Int
28+
) {
29+
self.year = year
30+
self.month = month
31+
self.day = day
32+
self.hour = hour
33+
self.minute = minute
34+
self.second = second
35+
self.weekday = weekday
36+
}
37+
}
38+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// File.swift
3+
// swift-rfc-5322
4+
//
5+
// Created by Coen ten Thije Boonkkamp on 18/11/2025.
6+
//
7+
8+
extension RFC_5322.Date {
9+
10+
/// Errors that can occur when parsing RFC 5322 date-time strings
11+
public enum Error: Swift.Error, Sendable, Equatable {
12+
case invalidFormat(String)
13+
case invalidDayName(String)
14+
case invalidDay(String)
15+
case invalidMonth(String)
16+
case invalidYear(String)
17+
case invalidTime(String)
18+
case invalidHour(String)
19+
case invalidMinute(String)
20+
case invalidSecond(String)
21+
case invalidTimezone(String)
22+
case weekdayMismatch(expected: String, actual: String)
23+
}
24+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//
2+
// File.swift
3+
// swift-rfc-5322
4+
//
5+
// Created by Coen ten Thije Boonkkamp on 18/11/2025.
6+
//
7+
8+
import Foundation

Sources/RFC_5322/Header.swift renamed to Sources/RFC_5322/RFC_5322.Header.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import Foundation
21

32
extension RFC_5322 {
43
/// Email header field (name-value pair)

0 commit comments

Comments
 (0)