address4 - multiple declarations
Function address4
Parses a string containing an IPv4 address in dotted-decimal notation.
Option!Address4 address4(R)
(
R range
)
if (isForwardRange!R && is(Unqual!(ElementType!R) == char) && hasLength!R);
Parameters
Name | Description |
---|---|
R | Input range type. |
range | Stringish range containing the address. |
Returns
Option containing the address if the parsing was successful, or nothing otherwise.
Function address4
Constructs an Address4 from raw bytes in network byte order.
Parameters
Name | Description |
---|---|
R | Input range type. |
range | ubyte range containing the address. |
Returns
Option containing the address if the range contains exactly 4 bytes, or nothing otherwise.
Example
{
ubyte[4] actual = [127, 0, 0, 1];
assert(address4(actual[]) .get .isLoopback());
}
{
ubyte[3] actual = [127, 0, 0];
assert(address4(actual[]) .isNothing);
}
{
ubyte[5] actual = [127, 0, 0, 0, 1];
assert(address4(actual[]) .isNothing);
}