OxL Reference

method IpAddr.parse

Parses numeric IPv4 / IPv6 text (names are not resolved: see dns.lookup).

Example:

oxl✓ checked in CI
use std.net { IpAddr }

fn main() io {
  match IpAddr.parse("10.0.0.256") {
    IpAddr ip => print(ip.toString())
    ParseError e => print(e.msg)
  }
}
Output
invalid IP address `10.0.0.256`
pub(api) static fn parse(text: str) -> IpAddr | ParseError

Complexity. O(n) in the length of the text.

Since. 1.0.0-beta

Parameters

NameType
textstr

Returns

IpAddr

Errors

  • ParseError @error
  • `ParseError` for text that is not a numeric IPv4 or IPv6 address (names are not resolved).

Effects

none declared (pure unless the body says otherwise)

Defined in: std/net/net.oxl:131

See also