Skip to content

Commit 060f6d4

Browse files
committed
Add Codable to RFC_5322.Message and CustomStringConvertible to LocalPart
Protocol conformance improvements: - RFC_5322.Message: Add Codable for full message serialization - RFC_5322.EmailAddress.LocalPart: Add CustomStringConvertible for debugging Enables JSON/plist serialization of complete RFC 5322 messages and improves debugging output for local parts.
1 parent e0d7a23 commit 060f6d4

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Sources/RFC_5322/RFC 5322 Message.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extension RFC_5322 {
3232
///
3333
/// let emlContent = message.render()
3434
/// ```
35-
public struct Message: Hashable, Sendable {
35+
public struct Message: Hashable, Sendable, Codable {
3636
/// Originator - From field
3737
public let from: EmailAddress
3838

Sources/RFC_5322/RFC 5322.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ extension RFC_5322 {
107107
// MARK: - Local Part
108108
extension RFC_5322.EmailAddress {
109109
/// RFC 5322 compliant local-part
110-
public struct LocalPart: Hashable, Sendable {
110+
public struct LocalPart: Hashable, Sendable, CustomStringConvertible {
111111
private let storage: Storage
112112

113113
/// Initialize with a string
@@ -150,6 +150,9 @@ extension RFC_5322.EmailAddress {
150150
}
151151
}
152152

153+
/// Description for CustomStringConvertible
154+
public var description: String { stringValue }
155+
153156
// swiftlint:disable:next nesting
154157
private enum Storage: Hashable {
155158
case dotAtom(String) // Regular unquoted format

0 commit comments

Comments
 (0)