struct

Ipconv::IPv6

Inherits Comparable < Struct < Value < Object

Represents an IPv6 address backed by two 64-bit unsigned integers (hi and lo).

Constructors

new(hi : UInt64, lo : UInt64)

Creates an IPv6 address from high and low 64-bit unsigned integers.

Source
new(u128 : UInt128)

Creates an IPv6 address from a single 128-bit unsigned integer.

Source
new(groups : StaticArray(UInt16, 8))

Creates an IPv6 address from an 8-element UInt16 static array representing the 8 hextets.

Source
parse(input : String) : IPv6

Parses an IPv6 address from string input. Supports expanded, compressed (RFC 5952), and IPv4-mapped mixed notations.

Source

Instance methods

+(other : Int) : IPv6

Returns a new IPv6 address offset by other numeric positions. Raises OverflowError on bounds overflow or underflow.

Source
-(other : Int) : IPv6

Subtracts an integer offset from this IPv6 address. Raises OverflowError on bounds underflow or overflow.

Source
-(other : IPv6) : UInt128

Computes the address distance between this address and other. Raises OverflowError if self < other.

Source
<=>(other : IPv6) : Int32

Compares this IPv6 address with other by numeric 128-bit value.

Source
[](index : Int) : UInt16

Returns the 16-bit hextet value at index (0 to 7).

Source
groups

Returns an 8-element static array of 16-bit hextet values.

Source
hi

Returns the high 64 bits of the 128-bit IPv6 address.

Source
lo

Returns the low 64 bits of the 128-bit IPv6 address.

Source
mapped_ipv4

Returns the mapped IPv4 address if this address is an IPv4-mapped address (::ffff:x.x.x.x), or nil otherwise.

Source
pred

Returns the previous sequential IPv6 address. Raises OverflowError if already at ::.

Source
special

Returns the Special purpose designation for this IPv6 address, or Special::None.

Source
succ

Returns the next sequential IPv6 address. Raises OverflowError if already at ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff.

Source
to_compressed

Returns the canonically compressed string representation according to RFC 5952.

Source
to_expanded

Returns the fully expanded 8-hextet string representation (e.g. "2001:0DB8:0000:0000:0000:0000:0000:0001").

Source
to_mixed

Returns the IPv4-mapped mixed notation string if this address is an IPv4-mapped address (::ffff:x.x.x.x), or nil otherwise.

Source
to_s(io : IO) : Nil

Writes the canonically compressed IPv6 address to io.

Source
to_u128

Returns the 128-bit unsigned integer representation of this IPv6 address.

Source

Nested types