Skip to content

Commit ba95320

Browse files
authored
Merge pull request #564 from Comcast/topic/update-readme
Minor edits to guide
2 parents 5806166 + 0931a3a commit ba95320

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

docs/guide.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ The `ip` interpolator returns an `IpAddress`, the `ipv4` interpolator returns an
6363

6464
## IPv6 String Formats
6565

66-
IPv6 addresses have a number of special string formats. The default format (what's returned by `toString`) adheres to [RFC5952](https://tools.ietf.org/html/rfc5952) -- e.g., maximal use of `::` to condense string length. If instead, you want a string that does not use `::` and expresses each hextet as 4 characters, call `.toUncondensedString`. Note that the `toString` method never outputs a mixed string consisting of both V6 hextets and a dotted decimal V4 address. For example, the address consisting of 12 0 bytes followed by 127, 0, 0, 1 is rendered as `::7f00:1` instead of `::127.0.0.1`. `Ipv6Address.fromString` and `IpAddress.fromString` can parse all of these formats.
66+
IPv6 addresses have a number of special string formats. The default format (what's returned by `toString`) adheres to [RFC5952](https://tools.ietf.org/html/rfc5952) -- e.g., maximal use of `::` to condense string length. If instead you want a string that does not use `::` and expresses each hextet as 4 characters, call `.toUncondensedString`. Note that the `toString` method never outputs a mixed string consisting of both V6 hextets and a dotted decimal V4 address. For example, the address consisting of 12 0 bytes followed by 127, 0, 0, 1 is rendered as `::7f00:1` instead of `::127.0.0.1`. `Ipv6Address.fromString` and `IpAddress.fromString` can parse all of these formats.
6767

6868
```scala
6969
import com.comcast.ip4s._
@@ -98,11 +98,11 @@ When compiling for the JVM, the various IP address classes have a `toInetAddress
9898

9999
```scala
100100
val homeIA = ip"127.0.0.1".toInetAddress
101-
// homeIA: java.net.InetAddress = /127.0.0.1
101+
// homeIA: InetAddress = /127.0.0.1
102102
val home4IA = ipv4"127.0.0.1".toInetAddress
103-
// home4IA: java.net.Inet4Address = /127.0.0.1
103+
// home4IA: Inet4Address = /127.0.0.1
104104
val home6IA = ipv6"::1".toInetAddress
105-
// home6IA: java.net.InetAddress = /0:0:0:0:0:0:0:1
105+
// home6IA: InetAddress = /0:0:0:0:0:0:0:1
106106
```
107107

108108
# Multicast
@@ -133,16 +133,16 @@ To construct instances of `Multicast[A]` and `SourceSpecificMulticast[A]`, we ca
133133

134134
```scala
135135
val multicastIps = ips.flatMap(_.asMulticast)
136-
// multicastIps: List[com.comcast.ip4s.Multicast[IpAddress]] = List(224.10.10.10, 232.11.11.11, ff00::10, ff3b::11)
136+
// multicastIps: List[Multicast[IpAddress]] = List(224.10.10.10, 232.11.11.11, ff00::10, ff3b::11)
137137
val ssmIps = ips.flatMap(_.asSourceSpecificMulticast)
138-
// ssmIps: List[SourceSpecificMulticast.Strict[IpAddress]] = List(232.11.11.11, ff3b::11)
138+
// ssmIps: List[Strict[IpAddress]] = List(232.11.11.11, ff3b::11)
139139
```
140140

141141
It's common for source specific multicast to be used with group addresses outside the designated source specific multicast address range. To support such cases, use `asSourceSpecificMulticastLenient`:
142142

143143
```scala
144144
val lenient = ips.flatMap(_.asSourceSpecificMulticastLenient)
145-
// lenient: List[com.comcast.ip4s.SourceSpecificMulticast[IpAddress]] = List(224.10.10.10, 232.11.11.11, ff00::10, ff3b::11)
145+
// lenient: List[SourceSpecificMulticast[IpAddress]] = List(224.10.10.10, 232.11.11.11, ff00::10, ff3b::11)
146146
```
147147

148148
Additionally, the `SourceSpecificMulticast.Strict[A]` type provides the guarantee that the wrapped address is in the RFC defined source specific range.
@@ -172,17 +172,17 @@ case class AnySourceMulticastJoin[A <: IpAddress](group: Multicast[A]) extends M
172172
case class SourceSpecificMulticastJoin[A <: IpAddress](source: A, group: SourceSpecificMulticast[A]) extends MulticastJoin[A]
173173
```
174174

175-
`MulticastJoin` and its subtypes are parameterized by the address type in order to allow domain modelling that requires a V4, V6, or either. The `AnySourceMulticastJoin` and `SourceSpecificMulticastJoin` types are exposed, instead of being kept as an implementation detail (or data constructor), for a similar reason -- to allow modelling where a type or function wants a very specific type like `SourceSpecificMulticastJoin[Ipv6Address]` while supporting other scnenarios that want something much more general like a `MulticastJoin[IpAddress]`.
175+
`MulticastJoin` and its subtypes are parameterized by the address type in order to optionally constrain the join to V4 or V6 addresses. The `AnySourceMulticastJoin` and `SourceSpecificMulticastJoin` types are exposed, instead of being kept as an implementation detail (or data constructor), for a similar reason -- to allow modelling where a type or function wants a very specific type like `SourceSpecificMulticastJoin[Ipv6Address]` while supporting other scnenarios that want something much more general like a `MulticastJoin[IpAddress]`.
176176

177177
To construct a `MulticastJoin`, we can use the `asm` and `ssm` methods in the `MulticastJoin` companion.
178178

179179
```scala
180180
val j1 = MulticastJoin.ssm(ipv4"10.11.12.13", ssmipv4"232.1.2.3")
181-
// j1: com.comcast.ip4s.MulticastJoin[Ipv4Address] = 10.11.12.13@232.1.2.3
181+
// j1: MulticastJoin[Ipv4Address] = 10.11.12.13@232.1.2.3
182182
val j2 = MulticastJoin.ssm(ipv4"10.11.12.13", ipv4"232.1.2.3".asSourceSpecificMulticast.get)
183-
// j2: com.comcast.ip4s.MulticastJoin[Ipv4Address] = 10.11.12.13@232.1.2.3
183+
// j2: MulticastJoin[Ipv4Address] = 10.11.12.13@232.1.2.3
184184
val j3 = MulticastJoin.asm(mipv6"ff3b::10")
185-
// j3: com.comcast.ip4s.MulticastJoin[Ipv6Address] = ff3b::10
185+
// j3: MulticastJoin[Ipv6Address] = ff3b::10
186186
```
187187

188188
# CIDR
@@ -251,7 +251,7 @@ A socket address is an IP address and a TCP/UDP port number. This is roughly mod
251251
case class SocketAddress[+A <: IpAddress](ip: A, port: Port)
252252
```
253253

254-
Like we saw with `CIDR` and `MulticastJoin`, `SocketAddress` is polymorphic in address type, allowing expression of contraints like a socket address with an IPv6 IP. `SocketAddress` can be converted to and from a string representation, where V6 addresses are surrounded by square brackets.
254+
Like we saw with `CIDR` and `MulticastJoin`, `SocketAddress` is polymorphic in address type, allowing expression of constraints like a socket address with an IPv6 IP. `SocketAddress` can be converted to and from a string representation, where V6 addresses are surrounded by square brackets.
255255

256256
```scala
257257
val s = SocketAddress(ipv4"127.0.0.1", port"5555")
@@ -268,7 +268,7 @@ On the JVM, a `SocketAddress` can be converted to a `java.net.InetSocketAddress`
268268

269269
```scala
270270
val u = t.toInetSocketAddress
271-
// u: java.net.InetSocketAddress = /[0:0:0:0:0:0:0:1]:5555
271+
// u: InetSocketAddress = /[0:0:0:0:0:0:0:1]:5555
272272
```
273273

274274
## Multicast Socket Addresses
@@ -292,11 +292,11 @@ The `Hostname` type models an RFC1123 compliant hostname -- limited to 253 total
292292
val home = Hostname.fromString("localhost")
293293
// home: Option[Hostname] = Some(localhost)
294294
val ls = home.map(_.labels)
295-
// ls: Option[List[Hostname.Label]] = Some(List(localhost))
295+
// ls: Option[List[Label]] = Some(List(localhost))
296296
val comcast = host"comcast.com"
297297
// comcast: Hostname = comcast.com
298298
val cs = comcast.labels
299-
// cs: List[Hostname.Label] = List(comcast, com)
299+
// cs: List[Label] = List(comcast, com)
300300
```
301301

302302
## Hostname Resolution

docs/src/guide.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ The `ip` interpolator returns an `IpAddress`, the `ipv4` interpolator returns an
5454

5555
## IPv6 String Formats
5656

57-
IPv6 addresses have a number of special string formats. The default format (what's returned by `toString`) adheres to [RFC5952](https://tools.ietf.org/html/rfc5952) -- e.g., maximal use of `::` to condense string length. If instead, you want a string that does not use `::` and expresses each hextet as 4 characters, call `.toUncondensedString`. Note that the `toString` method never outputs a mixed string consisting of both V6 hextets and a dotted decimal V4 address. For example, the address consisting of 12 0 bytes followed by 127, 0, 0, 1 is rendered as `::7f00:1` instead of `::127.0.0.1`. `Ipv6Address.fromString` and `IpAddress.fromString` can parse all of these formats.
57+
IPv6 addresses have a number of special string formats. The default format (what's returned by `toString`) adheres to [RFC5952](https://tools.ietf.org/html/rfc5952) -- e.g., maximal use of `::` to condense string length. If instead you want a string that does not use `::` and expresses each hextet as 4 characters, call `.toUncondensedString`. Note that the `toString` method never outputs a mixed string consisting of both V6 hextets and a dotted decimal V4 address. For example, the address consisting of 12 0 bytes followed by 127, 0, 0, 1 is rendered as `::7f00:1` instead of `::127.0.0.1`. `Ipv6Address.fromString` and `IpAddress.fromString` can parse all of these formats.
5858

5959
```scala mdoc:reset:to-string
6060
import com.comcast.ip4s._
@@ -147,7 +147,7 @@ case class AnySourceMulticastJoin[A <: IpAddress](group: Multicast[A]) extends M
147147
case class SourceSpecificMulticastJoin[A <: IpAddress](source: A, group: SourceSpecificMulticast[A]) extends MulticastJoin[A]
148148
```
149149

150-
`MulticastJoin` and its subtypes are parameterized by the address type in order to allow domain modelling that requires a V4, V6, or either. The `AnySourceMulticastJoin` and `SourceSpecificMulticastJoin` types are exposed, instead of being kept as an implementation detail (or data constructor), for a similar reason -- to allow modelling where a type or function wants a very specific type like `SourceSpecificMulticastJoin[Ipv6Address]` while supporting other scnenarios that want something much more general like a `MulticastJoin[IpAddress]`.
150+
`MulticastJoin` and its subtypes are parameterized by the address type in order to optionally constrain the join to V4 or V6 addresses. The `AnySourceMulticastJoin` and `SourceSpecificMulticastJoin` types are exposed, instead of being kept as an implementation detail (or data constructor), for a similar reason -- to allow modelling where a type or function wants a very specific type like `SourceSpecificMulticastJoin[Ipv6Address]` while supporting other scnenarios that want something much more general like a `MulticastJoin[IpAddress]`.
151151

152152
To construct a `MulticastJoin`, we can use the `asm` and `ssm` methods in the `MulticastJoin` companion.
153153

@@ -207,7 +207,7 @@ A socket address is an IP address and a TCP/UDP port number. This is roughly mod
207207
case class SocketAddress[+A <: IpAddress](ip: A, port: Port)
208208
```
209209

210-
Like we saw with `CIDR` and `MulticastJoin`, `SocketAddress` is polymorphic in address type, allowing expression of contraints like a socket address with an IPv6 IP. `SocketAddress` can be converted to and from a string representation, where V6 addresses are surrounded by square brackets.
210+
Like we saw with `CIDR` and `MulticastJoin`, `SocketAddress` is polymorphic in address type, allowing expression of constraints like a socket address with an IPv6 IP. `SocketAddress` can be converted to and from a string representation, where V6 addresses are surrounded by square brackets.
211211

212212
```scala mdoc:nest:to-string
213213
val s = SocketAddress(ipv4"127.0.0.1", port"5555")

0 commit comments

Comments
 (0)