From 90845d178d20e56eddef1a89a8711f4d549b7d06 Mon Sep 17 00:00:00 2001 From: Joe Heck Date: Fri, 30 May 2025 12:44:14 -0700 Subject: [PATCH 1/2] converting to computer error conditions --- Sources/NTPClient/NTPError.swift | 36 +++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/Sources/NTPClient/NTPError.swift b/Sources/NTPClient/NTPError.swift index e7dabf1..e91aa31 100644 --- a/Sources/NTPClient/NTPError.swift +++ b/Sources/NTPClient/NTPError.swift @@ -17,23 +17,35 @@ public struct NTPError: Error, Equatable, Hashable, CustomStringConvertible { public var description: String { String(describing: self.base) } - - enum Base: Equatable, Hashable { + + @usableFromInline + enum Base: Equatable, Hashable, Sendable { case responseNotReceived case notEnoughBytes case versionNotSupported } - - private let base: Base - + + @usableFromInline + let base: Base + + @inlinable init(_ base: Base) { self.base = base } - + /// The client didn't receive a response from the NTP server. - public static let responseNotReceived = Self(.responseNotReceived) - + @inlinable + public static var responseNotReceived: Self { + Self(.responseNotReceived) + } + /// Received data packet is too small to be a valid NTP response. - public static let notEnoughBytes = Self(.notEnoughBytes) - - /// NTP version number in the server's response is not supported by the client. - public static let versionNotSupported = Self(.versionNotSupported) + @inlinable + public static var notEnoughBytes: Self { + Self(.notEnoughBytes) + } + + /// NTP version number in the server's response isn't supported by the client. + @inlinable + public static var versionNotSupported: Self { + Self(.versionNotSupported) + } } From f141ada299e04fd591c1587ba8c6d4b41085bef9 Mon Sep 17 00:00:00 2001 From: Joe Heck Date: Fri, 30 May 2025 12:47:43 -0700 Subject: [PATCH 2/2] formatting cleanup --- Sources/NTPClient/NTPError.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/NTPClient/NTPError.swift b/Sources/NTPClient/NTPError.swift index e91aa31..cc49ef4 100644 --- a/Sources/NTPClient/NTPError.swift +++ b/Sources/NTPClient/NTPError.swift @@ -17,32 +17,32 @@ public struct NTPError: Error, Equatable, Hashable, CustomStringConvertible { public var description: String { String(describing: self.base) } - + @usableFromInline enum Base: Equatable, Hashable, Sendable { case responseNotReceived case notEnoughBytes case versionNotSupported } - + @usableFromInline let base: Base - + @inlinable init(_ base: Base) { self.base = base } - + /// The client didn't receive a response from the NTP server. @inlinable public static var responseNotReceived: Self { Self(.responseNotReceived) } - + /// Received data packet is too small to be a valid NTP response. @inlinable public static var notEnoughBytes: Self { Self(.notEnoughBytes) } - + /// NTP version number in the server's response isn't supported by the client. @inlinable public static var versionNotSupported: Self {