sealed abstract class IpAddress extends IpAddressPlatform 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.
- Source
- IpAddress.scala
- Alphabetic
- By Inheritance
- IpAddress
- Serializable
- Serializable
- IpAddressPlatform
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
val
bytes: Array[Byte]
- Attributes
- protected
-
abstract
def
fold[A](v4: (Ipv4Address) ⇒ A, v6: (Ipv6Address) ⇒ A): A
Converts this address to a value of type
Ausing the supplied functions. -
abstract
def
isMulticast: Boolean
Returns true if this address is in the multicast range.
-
abstract
def
isSourceSpecificMulticast: Boolean
Returns true if this address is in the source specific multicast range.
-
abstract
def
next: IpAddress
Gets the IP address after this address, with overflow from the maximum value to the minimum value.
-
abstract
def
previous: IpAddress
Gets the IP address before this address, with underflow from minimum value to the maximum value.
-
abstract
def
toInetAddress: InetAddress
Converts this address to a
java.net.InetAddress.Converts this address to a
java.net.InetAddress. Note this method only exists on the JVM.- Definition Classes
- IpAddressPlatform
-
abstract
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).
-
abstract
def
transform(v4: (Ipv4Address) ⇒ Ipv4Address, v6: (Ipv6Address) ⇒ Ipv6Address): IpAddress.this.type
Maps a type-preserving function across this IP address.
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- def ->[B](y: B): (IpAddress, B)
-
def
/(prefixBits: Int): Cidr[IpAddress.this.type]
Constructs a Cidr address from this address.
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
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.
-
def
asMulticast: Option[Multicast[IpAddress.this.type]]
Converts this address to a multicast address, as long as it is in the multicast address range.
-
def
asSourceSpecificMulticast: Option[SourceSpecificMulticast[IpAddress.this.type]]
Converts this address to a source specific multicast address, as long as it is in the source specific multicast address range.
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
- def ensuring(cond: (IpAddress) ⇒ Boolean, msg: ⇒ Any): IpAddress
- def ensuring(cond: (IpAddress) ⇒ Boolean): IpAddress
- def ensuring(cond: Boolean, msg: ⇒ Any): IpAddress
- def ensuring(cond: Boolean): IpAddress
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(other: Any): Boolean
- Definition Classes
- IpAddress → AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
- def formatted(fmtstr: String): String
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- IpAddress → AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toBytes: Array[Byte]
Converts this address to a network order byte array of either 4 or 16 bytes.
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
- def →[B](y: B): (IpAddress, B)