Skip to content

Commit 8865bc9

Browse files
authored
Make IP/CIDR types conform to Codable (#454)
These types can benefit from swift's automatic synthesis as the properties already conform to Codable. This will give some flexibility for clients using these types to not have to add extension and implement the encoding / decoding separately.
1 parent 57d6e0b commit 8865bc9

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

Sources/ContainerizationExtras/CIDRv4.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/// Describes an IPv4 CIDR address block.
1818
@frozen
19-
public struct CIDRv4: CustomStringConvertible, Equatable, Sendable, Hashable {
19+
public struct CIDRv4: CustomStringConvertible, Equatable, Sendable, Hashable, Codable {
2020
/// The IP component of this CIDR address.
2121
public let address: IPv4Address
2222

Sources/ContainerizationExtras/CIDRv6.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/// Describes an IPv4 or IPv6 CIDR address block.
1818
@frozen
19-
public struct CIDRv6: CustomStringConvertible, Equatable, Sendable, Hashable {
19+
public struct CIDRv6: CustomStringConvertible, Equatable, Sendable, Hashable, Codable {
2020

2121
/// The IP component of this CIDR address.
2222
public let address: IPv6Address

Sources/ContainerizationExtras/IPv4Address.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//===----------------------------------------------------------------------===//
1616

1717
@frozen
18-
public struct IPv4Address: Sendable, Hashable, CustomStringConvertible, Equatable, Comparable {
18+
public struct IPv4Address: Sendable, Hashable, CustomStringConvertible, Equatable, Comparable, Codable {
1919
public let value: UInt32
2020

2121
@inlinable

Sources/ContainerizationExtras/IPv6Address.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//===----------------------------------------------------------------------===//
1616

1717
/// Represents an IPv6 network address conforming to RFC 5952 and RFC 4291.
18-
public struct IPv6Address: Sendable, Hashable, CustomStringConvertible, Equatable, Comparable {
18+
public struct IPv6Address: Sendable, Hashable, CustomStringConvertible, Equatable, Comparable, Codable {
1919
@usableFromInline
2020
internal let value: UInt128
2121

Sources/ContainerizationExtras/Prefix.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/// CIDR prefix length (e.g., `/24` for a 24-bit network mask).
1818
@frozen
19-
public struct Prefix: Sendable, CustomStringConvertible, Hashable {
19+
public struct Prefix: Sendable, CustomStringConvertible, Hashable, Codable {
2020
public let length: UInt8
2121

2222
/// Create a prefix (0-128). Use `ipv4(_:)` or `ipv6(_:)` for version-specific validation.

0 commit comments

Comments
 (0)