ipaddr
IP Address parsing and printing per specification.
Parsing of both v4 and v6 and printing of v4 from rfc3986:
- https://tools.ietf.org/html/rfc3986
Printing of V6 from rfc5952
- https://tools.ietf.org/html/rfc5952
Types
pub type IpAddress { IpV4(Int, Int, Int, Int) IpV6(Int, Int, Int, Int, Int, Int, Int, Int) }
Constructors
-
IpV4(Int, Int, Int, Int)
-
IpV6(Int, Int, Int, Int, Int, Int, Int, Int)
Functions
pub fn from_string(str: String) -> Result(IpAddress, Nil)
Parse an Ip Address from the front of a String.
Example Supported Addresses:
- Standard v4 : d.d.d.d where d is in decimal
- Standard v6 : x:x:x:x:x:x:x:x where x is in hex | x::x , ::x, x::, ::, etc
- v6 with trailing v4 : x:x:x:x:x:x:d.d.d.d where x is in hex and d is in decimal
pub fn to_string(addr: IpAddress) -> String
Print an Ip Address to String. Will print either a standard IpV4 or IpV6 address.