Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Sources/AsyncDNSResolver/AsyncDNSResolver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ public struct AsyncDNSResolver {
}

/// See ``DNSResolver/queryCNAME(name:)``.
public func queryCNAME(name: String) async throws -> String {
public func queryCNAME(name: String) async throws -> String? {
try await self.underlying.queryCNAME(name: name)
}

/// See ``DNSResolver/querySOA(name:)``.
public func querySOA(name: String) async throws -> SOARecord {
public func querySOA(name: String) async throws -> SOARecord? {
try await self.underlying.querySOA(name: name)
}

Expand Down Expand Up @@ -102,15 +102,15 @@ public protocol DNSResolver {
/// - Parameters:
/// - name: The name to resolve.
///
/// - Returns: ``ARecord``s for the given name.
/// - Returns: ``ARecord``s for the given name, empty if no records were found.
func queryA(name: String) async throws -> [ARecord]

/// Lookup AAAA records associated with `name`.
///
/// - Parameters:
/// - name: The name to resolve.
///
/// - Returns: ``AAAARecord``s for the given name.
/// - Returns: ``AAAARecord``s for the given name, empty if no records were found.
func queryAAAA(name: String) async throws -> [AAAARecord]

/// Lookup NS record associated with `name`.
Expand All @@ -126,16 +126,16 @@ public protocol DNSResolver {
/// - Parameters:
/// - name: The name to resolve.
///
/// - Returns: CNAME for the given name.
func queryCNAME(name: String) async throws -> String
/// - Returns: CNAME for the given name, `nil` if no record was found.
func queryCNAME(name: String) async throws -> String?

/// Lookup SOA record associated with `name`.
///
/// - Parameters:
/// - name: The name to resolve.
///
/// - Returns: ``SOARecord`` for the given name.
func querySOA(name: String) async throws -> SOARecord
/// - Returns: ``SOARecord`` for the given name, `nil` if no record was found.
func querySOA(name: String) async throws -> SOARecord?

/// Lookup PTR record associated with `name`.
///
Expand All @@ -150,23 +150,23 @@ public protocol DNSResolver {
/// - Parameters:
/// - name: The name to resolve.
///
/// - Returns: ``MXRecord``s for the given name.
/// - Returns: ``MXRecord``s for the given name, empty if no records were found.
func queryMX(name: String) async throws -> [MXRecord]

/// Lookup TXT records associated with `name`.
///
/// - Parameters:
/// - name: The name to resolve.
///
/// - Returns: ``TXTRecord``s for the given name.
/// - Returns: ``TXTRecord``s for the given name, empty if no records were found.
func queryTXT(name: String) async throws -> [TXTRecord]

/// Lookup SRV records associated with `name`.
///
/// - Parameters:
/// - name: The name to resolve.
///
/// - Returns: ``SRVRecord``s for the given name.
/// - Returns: ``SRVRecord``s for the given name, empty if no records were found.
func querySRV(name: String) async throws -> [SRVRecord]
}

Expand Down
5 changes: 0 additions & 5 deletions Sources/AsyncDNSResolver/Errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ extension AsyncDNSResolver {
public struct Error: Swift.Error, Hashable, CustomStringConvertible {
public struct Code: Hashable, Sendable {
fileprivate enum Value: Hashable, Sendable {
case noData
case invalidQuery
case serverFailure
case notFound
Expand Down Expand Up @@ -50,8 +49,6 @@ extension AsyncDNSResolver {
self.value = value
}

public static var noData: Self { Self(.noData) }

public static var invalidQuery: Self { Self(.invalidQuery) }

public static var serverFailure: Self { Self(.serverFailure) }
Expand Down Expand Up @@ -113,8 +110,6 @@ extension AsyncDNSResolver {

public var description: String {
switch self.code.value {
case .noData:
return "no data: \(self.message)"
case .invalidQuery:
return "invalid query: \(self.message)"
case .serverFailure:
Expand Down
Loading