@@ -184,7 +184,7 @@ enum QueryType {
184
184
185
185
// MARK: - Query reply types
186
186
187
- public enum IPAddress : Sendable , Equatable , CustomStringConvertible {
187
+ public enum IPAddress : Sendable , Hashable , CustomStringConvertible {
188
188
case ipv4( IPv4 )
189
189
case ipv6( IPv6 )
190
190
@@ -216,33 +216,47 @@ public enum IPAddress: Sendable, Equatable, CustomStringConvertible {
216
216
}
217
217
}
218
218
219
- public struct ARecord : Sendable , Equatable , CustomStringConvertible {
219
+ public struct ARecord : Sendable , Hashable , CustomStringConvertible {
220
220
public let address : IPAddress . IPv4
221
221
public let ttl : Int32 ?
222
222
223
223
public var description : String {
224
224
" \( Self . self) (address= \( self . address) , ttl= \( self . ttl. map { " \( $0) " } ?? " " ) ) "
225
225
}
226
+
227
+ public init ( address: IPAddress . IPv4 , ttl: Int32 ? ) {
228
+ self . address = address
229
+ self . ttl = ttl
230
+ }
226
231
}
227
232
228
- public struct AAAARecord : Sendable , Equatable , CustomStringConvertible {
233
+ public struct AAAARecord : Sendable , Hashable , CustomStringConvertible {
229
234
public let address : IPAddress . IPv6
230
235
public let ttl : Int32 ?
231
236
232
237
public var description : String {
233
238
" \( Self . self) (address= \( self . address) , ttl= \( self . ttl. map { " \( $0) " } ?? " " ) ) "
234
239
}
240
+
241
+ public init ( address: IPAddress . IPv6 , ttl: Int32 ? ) {
242
+ self . address = address
243
+ self . ttl = ttl
244
+ }
235
245
}
236
246
237
- public struct NSRecord : Sendable , Equatable , CustomStringConvertible {
247
+ public struct NSRecord : Sendable , Hashable , CustomStringConvertible {
238
248
public let nameservers : [ String ]
239
249
240
250
public var description : String {
241
251
" \( Self . self) (nameservers= \( self . nameservers) ) "
242
252
}
253
+
254
+ public init ( nameservers: [ String ] ) {
255
+ self . nameservers = nameservers
256
+ }
243
257
}
244
258
245
- public struct SOARecord : Sendable , Equatable , CustomStringConvertible {
259
+ public struct SOARecord : Sendable , Hashable , CustomStringConvertible {
246
260
public let mname : String ?
247
261
public let rname : String ?
248
262
public let serial : UInt32
@@ -256,32 +270,45 @@ public struct SOARecord: Sendable, Equatable, CustomStringConvertible {
256
270
}
257
271
}
258
272
259
- public struct PTRRecord : Sendable , Equatable , CustomStringConvertible {
273
+ public struct PTRRecord : Sendable , Hashable , CustomStringConvertible {
260
274
public let names : [ String ]
261
275
262
276
public var description : String {
263
277
" \( Self . self) (names= \( self . names) ) "
264
278
}
279
+
280
+ public init ( names: [ String ] ) {
281
+ self . names = names
282
+ }
265
283
}
266
284
267
- public struct MXRecord : Sendable , Equatable , CustomStringConvertible {
285
+ public struct MXRecord : Sendable , Hashable , CustomStringConvertible {
268
286
public let host : String
269
287
public let priority : UInt16
270
288
271
289
public var description : String {
272
290
" \( Self . self) (host= \( self . host) , priority= \( self . priority) ) "
273
291
}
292
+
293
+ public init ( host: String , priority: UInt16 ) {
294
+ self . host = host
295
+ self . priority = priority
296
+ }
274
297
}
275
298
276
- public struct TXTRecord : Sendable , Equatable {
299
+ public struct TXTRecord : Sendable , Hashable {
277
300
public let txt : String
278
301
279
302
public var description : String {
280
303
" \( Self . self) ( \( self . txt) ) "
281
304
}
305
+
306
+ public init ( txt: String ) {
307
+ self . txt = txt
308
+ }
282
309
}
283
310
284
- public struct SRVRecord : Sendable , Equatable , CustomStringConvertible {
311
+ public struct SRVRecord : Sendable , Hashable , CustomStringConvertible {
285
312
public let host : String
286
313
public let port : UInt16
287
314
public let weight : UInt16
@@ -290,9 +317,16 @@ public struct SRVRecord: Sendable, Equatable, CustomStringConvertible {
290
317
public var description : String {
291
318
" \( Self . self) (host= \( self . host) , port= \( self . port) , weight= \( self . weight) , priority= \( self . priority) ) "
292
319
}
320
+
321
+ public init ( host: String , port: UInt16 , weight: UInt16 , priority: UInt16 ) {
322
+ self . host = host
323
+ self . port = port
324
+ self . weight = weight
325
+ self . priority = priority
326
+ }
293
327
}
294
328
295
- public struct NAPTRRecord : Sendable , Equatable , CustomStringConvertible {
329
+ public struct NAPTRRecord : Sendable , Hashable , CustomStringConvertible {
296
330
public let flags : String ?
297
331
public let service : String ?
298
332
public let regExp : String ?
@@ -303,4 +337,13 @@ public struct NAPTRRecord: Sendable, Equatable, CustomStringConvertible {
303
337
public var description : String {
304
338
" \( Self . self) (flags= \( self . flags ?? " " ) , service= \( self . service ?? " " ) , regExp= \( self . regExp ?? " " ) , replacement= \( self . replacement) , order= \( self . order) , preference= \( self . preference) ) "
305
339
}
340
+
341
+ public init ( flags: String ? , service: String ? , regExp: String ? , replacement: String , order: UInt16 , preference: UInt16 ) {
342
+ self . flags = flags
343
+ self . service = service
344
+ self . regExp = regExp
345
+ self . replacement = replacement
346
+ self . order = order
347
+ self . preference = preference
348
+ }
306
349
}
0 commit comments