net::ip+x86_64 +linux

Index

Types

type addr = (addr4 | addr6);
type addr4 = [4]u8;
type addr6 = [16]u8;
type subnet = struct {
	addr: addr,
	mask: addr,
};

Errors

type invalid = !void;

Globals

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

Functions

fn equal(l: addr, r: addr) bool;
fn fmt(s: io::handle, item: (...addr | subnet)) (size | io::error);
fn parse(s: str) (addr | invalid);
fn parsecidr(st: str) (subnet | invalid);
fn parsev4(st: str) (addr4 | invalid);
fn parsev6(st: str) (addr6 | invalid);
fn string(item: (...addr | subnet)) str;
fn subnet_contains(sub: subnet, item: (addr | subnet)) bool;

// Undocumented functions:
fn from_native(a: rt::sockaddr) (addr, u16);
fn to_native(a: addr, port: 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)) (size | io::error);

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 parsev4[link]

fn parsev4(st: str) (addr4 | invalid);

Parses an IPv4 address.

fn parsev6[link]

fn parsev6(st: str) (addr6 | invalid);

Parses an IPv6 address.

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;