IpAddress

sealed abstract class IpAddress extends IpAddressPlatform with Host with Serializable
Immutable and safe representation of an IP address, either V4 or V6.
=== Construction ===
IpAddress instances are constructed in a few different ways:
- via IpAddress("127.0.0.1"), which parses a string representation of the IP and returns an Option[IpAddress]
- via IpAddress.fromBytes(arr), which returns an IP address if the supplied array is either exactly 4 bytes or exactly 16 bytes
- via literal syntax like ip"127.0.0.1", which returns an IpAddress and fails to compile if the IP is invalid.
=== Type Hierarchy ===
There are two subtypes of IpAddress -- Ipv4Address and Ipv6Address. Each of these subtypes have a richer
API than IpAddress and it is often useful to use those types directly, for example if your use case requires a V6 address.
It is safe to pattern match on IpAddress to access Ipv4Address or Ipv6Address directly, or alternatively, you can use fold.
=== JVM Specific API ===
If using IpAddress on the JVM, you can call toInetAddress to convert the address to a java.net.InetAddress, for use
with networking libraries. This method does not exist on the Scala.js version.
Companion
object
trait Serializable
trait Host
trait Ordered[Host]
trait Comparable[Host]
trait HostPlatform
trait IpAddressPlatform
class Object
trait Matchable
class Any

Value members

Methods

def toBytes: Array[Byte]
Converts this address to a network order byte array of either 4 or 16 bytes.
def fold[A](v4: Ipv4Address => A, v6: Ipv6Address => A): A
Converts this address to a value of type A using the supplied functions.
Maps a type-preserving function across this IP address.
def isMulticast: Boolean
Returns true if this address is in the multicast range.
Converts this address to a multicast address, as long as it is in the multicast address range.
Returns true if this address is in the source specific multicast range.
Converts this address to a source specific multicast address, as long as it is in the source specific multicast address range.
def asIpv4: Option[Ipv4Address]
Narrows this address to an Ipv4Address if that is the underlying type.
def asIpv6: Option[Ipv6Address]
Narrows this address to an Ipv6Address if that is the underlying type.
Returns the version of this address.
def /(prefixBits: Int): Cidr[IpAddress]
Constructs a Cidr address from this address.
def toUriString: String
Converts this address to a string form that is compatible for use in a URI per RFC3986
(namely, IPv6 addresses are rendered in condensed form and surrounded by brackets).
override def equals(other: Any): Boolean
Definition Classes
Any
override def hashCode: Int
Definition Classes
Any

Inherited methods

def >(that: A): Boolean
Inhertied from
Ordered
def toInetAddress: InetAddress
Converts this address to a java.net.InetAddress. Note this method only exists on the JVM.
Inhertied from
IpAddressPlatform
def <(that: A): Boolean
Inhertied from
Ordered
def compareTo(that: A): Int
Inhertied from
Ordered
def <=(that: A): Boolean
Inhertied from
Ordered
def resolveOption[F <: ([_$2] =>> Any)](evidence$3: Dns[F], evidence$4: ApplicativeThrow[F]): F[Option[IpAddress]]
Resolves this host to an ip address using the platform DNS resolver.
If the host cannot be resolved, a None is returned.
Inhertied from
HostPlatform
def resolveAll[F <: ([_$4] =>> Any)](evidence$5: Dns[F], evidence$6: Applicative[F]): F[List[IpAddress]]
Resolves this host to all ip addresses known to the platform DNS resolver.
If the host cannot be resolved, an empty list is returned.
Inhertied from
HostPlatform
def >=(that: A): Boolean
Inhertied from
Ordered
def compare(that: Host): Int
Inhertied from
Host
def resolve[F <: ([_$1] =>> Any)](evidence$1: Dns[F], evidence$2: Applicative[F]): F[IpAddress]
Resolves this host to an ip address using the platform DNS resolver.
If the host cannot be resolved, the effect fails with a java.net.UnknownHostException.
Inhertied from
HostPlatform