net::ip +linux +x86_64

Index

Types

type addr;
type addr4;
type addr6;
type subnet;

Errors

type invalid;

Globals

let ANY_V4: addr4;
let ANY_V6: addr6;
let LOCAL_V4: addr4;
let LOCAL_V6: addr6;

Functions

fn equal(addr, addr) bool;
fn fmt(io::handle, (...addr | subnet)) (io::error | size);
fn parse(str) (addr | invalid);
fn parsecidr(str) (subnet | invalid);
fn string((...addr | subnet)) str;
fn subnet_contains(subnet, (addr | subnet)) bool;

// Undocumented functions:
fn from_native(rt::sockaddr) (addr, u16);
fn to_native(addr, u16) rt::sockaddr;

Types

type addr[link]

type addr = (addr4 | addr6);

An IP address.

type addr4[link]

type addr4 = [4]u8;

An IPv4 address.

type addr6[link]

type addr6 = [16]u8;

An IPv6 address.

type subnet[link]

type subnet = struct {
	addr: addr,
	mask: addr,
};

An IP subnet.

Errors

type invalid[link]

type invalid = !void;

Invalid parse result.

Globals

let ANY_V4[link]

const ANY_V4: addr4;

An IPv4 address which represents "any" address, i.e. "0.0.0.0". Binding to this address will listen on all available IPv4 interfaces on most systems.

let ANY_V6[link]

const ANY_V6: addr6;

An IPv6 address which represents "any" address, i.e. "::". Binding to this address will listen on all available IPv6 interfaces on most systems.

let LOCAL_V4[link]

const LOCAL_V4: addr4;

An IPv4 address which represents the loopback address, i.e. "127.0.0.1".

let LOCAL_V6[link]

const LOCAL_V6: addr6;

An IPv6 address which represents the loopback address, i.e. "::1".

Functions

fn equal[link]

fn equal(l: addr, r: addr) bool;

Test if two addrs are equal.

fn fmt[link]

fn fmt(s: io::handle, item: (...addr | subnet)) (io::error | size);

Formats an addr or subnet and prints it to a stream.

fn parse[link]

fn parse(s: str) (addr | invalid);

Parses an IP address.

fn parsecidr[link]

fn parsecidr(st: str) (subnet | invalid);

Parse an IP subnet in CIDR notation e.g. 192.168.1.0/24

fn string[link]

fn string(item: (...addr | subnet)) str;

Formats an addr or subnet as a string. The return value is statically allocated and will be overwritten on subsequent calls; see strings::dup to extend its lifetime.

fn subnet_contains[link]

fn subnet_contains(sub: subnet, item: (addr | subnet)) bool;

Returns whether an addr (or another subnet) is contained within a subnet.

fn from_native[link]

Show undocumented member
fn from_native(a: rt::sockaddr) (addr, u16);

fn to_native[link]

Show undocumented member
fn to_native(a: addr, port: u16) rt::sockaddr;