Skip to main content

parse

Function parse 

Source
pub fn parse(
    addr: &str,
    default_port: u16,
) -> Result<(&str, u16, bool), McError>
Expand description

Parse an address string into (host, port, explicit_port).

explicit_port is true when a port was present in the string, false when default_port was used as a fallback. This flag is used by McClient to decide whether to attempt an SRV lookup — SRV is skipped when the caller already specified an explicit port.

§Supported formats

  • "hostname" — uses default_port
  • "hostname:port" — uses the given port
  • "[::1]" — IPv6 without port, uses default_port
  • "[::1]:port" — IPv6 with port
  • "::1" — bare IPv6 (detected by multiple colons), uses default_port

§Errors