V4
An IPv4 address, which is 32 bits wide.
@frozen struct V4
An IPv4 address, which is 32 bits wide.
@frozen struct V4
import IP
This Foundation-free module provides tools for parsing and formatting IP addresses, and data structures for performing efficient IP address lookups.
@frozen enum IP
The namespace for IP types.
protocol Address : Comparable, Hashable, LosslessStringConvertible, Sendable
Abstracts over IP.V4
and IP.V6
addresses.
@frozen struct V6
An IPv6 address, which is 128 bits wide.
@frozen struct Block<Base> where Base : IP.Address
A representation of a CIDR block.
protocol BitwiseCopyable
protocol Comparable : Equatable
A type that can be compared using the relational operators <
, <=
, >=
, and >
.
protocol Copyable
A type whose values can be implicitly or explicitly copied.
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Escapable
protocol ExpressibleByIntegerLiteral
A type that can be initialized with an integer literal.
protocol Hashable : Equatable
A type that can be hashed into a Hasher
to produce an integer hash value.
protocol LosslessStringConvertible : CustomStringConvertible
A type that can be represented as a string in a lossless, unambiguous way.
protocol Sendable
init?(_ description: some StringProtocol)
Parses an IPv4 address from a string in dotted-decimal notation.
init(_ a: UInt8, _ b: UInt8, _ c: UInt8, _ d: UInt8)
init(storage: UInt32)
Creates an IPv4 address by wrapping a raw big-endian integer.
static var localhost: `Self` { get }
Returns the most common loopback address, 127.0.0.1
. Most people reaching for this API actually want IP.Block.loopback
, which models the entire loopback range.
var description: String { get }
Formats the address as a string in dotted-decimal notation.
var storage: UInt32
The raw address, in big-endian byte order.
init(value: Storage)
Initializes an IP address from a logical value.
var value: Storage { get }
The logical value of the address.
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.
static func ... (minimum: Self) -> PartialRangeFrom<Self>
Returns a partial range extending upward from a lower bound.
static func ... (maximum: Self) -> PartialRangeThrough<Self>
Returns a partial range up to, and including, its upper bound.
static func ... (minimum: Self, maximum: Self) -> ClosedRange<Self>
Returns a closed range that contains both of its bounds.
static func ..< (maximum: Self) -> PartialRangeUpTo<Self>
Returns a partial range up to, but not including, its upper bound.
static func ..< (minimum: Self, maximum: Self) -> Range<Self>
Returns a half-open range that contains its lower bound but not its upper bound.
static func / (self: Self, bits: UInt8) -> IP.Block<Self>
Creates a CIDR block by masking this IP address to the specified number of bits. The meaning of the slash (/
) operator follows CIDR notation.
static func < (a: Self, b: Self) -> Bool
Compares two IP addresses by their logical value
.
static func <= (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is less than or equal to that of the second argument.
static func > (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than that of the second argument.
static func >= (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether the value of the first argument is greater than or equal to that of the second argument.
func onesMasked(to bits: UInt8) -> Self
Replaces all bits in the IP address except for the leading number of bits
with 1.
func zeroMasked(to bits: UInt8) -> Self
Replaces all bits in the IP address except for the leading number of bits
with 0.
import IP_BSON
protocol BinaryPackable<Storage>
import IP_NIOCore
This module provides shims for compatibility with SwiftNIO’s IPv4Address
and IPv6Address
types.
init(_ ip: SocketAddress.IPv4Address)
Creates an IPv4 address from an IPv4Address
.