net::address
Addresses: IP addresses, the address-plus-port pair every socket constructor takes, and a URL parser.
module net::address::ip;
module net::address::socket_address;
module net::address::url;
internal module net::address::socket_address_storage;
export std::net::address::ip::{ IpAddress, IpV4Address, IpV6Address };
export std::net::address::socket_address::{ SocketAddress };
export std::net::address::url::{ Url, UrlError };
| File | What it holds | Import |
|---|---|---|
ip | IpV4Address, IpV6Address, IpAddress | import std::net::address::ip; |
socket_address | SocketAddress | import std::net::address::socket_address; |
url | Url, UrlError | import std::net::address::url; |
net::address::socket_address_storage packs a SocketAddress into the C sockaddr storage the socket calls take, and reads one back. It is internal to the standard library and has no page.
IPv6 addressing is parsed and represented, and TCP opens an
AF_INET6socket for a v6 address. UDP is IPv4-only for now:bind,connect, andsend_toreject anIpAddress::V6up front withUnsupported.
module collections::array;
module { a::b; a::c; }
internal module a::detail;In a directory's _module.cryo aggregator, declares a submodule. A module is public; internal module keeps it and everything it declares to its own package. The line is structure only: reaching the child's names still takes an import or an export.
internal function name() { ... }
internal module a::detail;
internal:Visible to every module of the declaring package - one cryoconfig project - and to none of another's. Written wherever private can be, on items and members alike. A function reached from another package is E0353, a type named from there is E0503, and a public signature may not name an internal type (E0506).
namespace std::net::address::socket_address_storage;sockaddr_in packing/unpacking + socket-option helpers.
export a::b::Name;
export a::b::{ X, Y as Z };Passes a name this module did not declare on to its importers, exactly as if they had imported the same path - how an aggregator presents a flat surface over its files. Every hop is explicit, and there is no glob form.
language referencetype enum IpAddress {
V4(IpV4Address);
V6(IpV6Address);
}An IP address of either family. parse picks the family from the text (a : means IPv6), and Display writes the family's own form.
type struct IpV4Address {
a: u8;
b: u8;
c: u8;
d: u8;
}An IPv4 address as its four octets, a.b.c.d, a the most significant. Printed in dotted decimal by Display.
type struct IpV6Address {
segments: [u8; 16];
}Sixteen octets in network byte order. parse accepts the canonical text forms (full 8-group, ::-compressed, and trailing embedded-v4); addresses may also be constructed directly.
type struct SocketAddress {
ip: IpAddress;
port: u16;
}An IP address and a port: the endpoint a socket binds or connects to. Printed as a.b.c.d:port, or [v6]:port for IPv6.
type struct Url {
scheme: Str;
host: Str;
port: u16;
path: Str;
query: Option<Str>;
fragment: Option<Str>;
}An absolute URL split into its parts, each a view into the text it was parsed from (keep that text alive while the Url is used). port is the scheme's default when the URL names none, and 0 for a scheme with no known default; path is / when the URL has none; query and fragment exclude their ? and #.
type enum UrlError with [Eq, Clone, Debug] {
MissingScheme;
EmptyScheme;
EmptyHost;
InvalidPort;
}Why a URL failed to parse.
std::net::address::urlimport a::b;
import a::b::{ X, Y };
import a::b as c;
import a::b::*;Brings a module, or selected items from it, into scope. One path per declaration: use the brace form for several items, as to alias, and * for everything public (prefer the brace form; wildcards invite name collisions).
AddressFamily::AF_INET6 = 10IpAddress::V6(IpV6Address)IoErrorKind::UnsupportedThe operation is recognized but not implemented on this build (e.g. a feature stubbed pending implementation, or a platform the stdlib doesn't support yet). Distinct from InvalidInput (caller's fault) and Other (unmapped errno).