std/os/macaddress

std/os/src/macaddress.trb

MacAddress: the hardware address of a network interface, as a value like any other (docs/design/OS.md section 5.5). It lives in std/os and in a module of its own, and not in std/ip, because it is a link-layer address and std/ip holds nothing that is not IP; it reads nothing from the machine, so parsing one needs no capability.

type MacAddress

type MacAddress with Show, Equals, Hash, TryFrom<String, AddressError>

A MAC address: six octets, held as one number of 48 bits. show() is the form that most systems print: lower case, two digits per octet, separated by colons.

Examples

const address = MacAddress.tryFrom("3C-22-FB-0A-1B-9E")?
print address
// prints 3c:22:fb:0a:1b:9e

fn of

static fn of(octets: List<Int>): Result<Self, AddressError>

The address of six octets, most significant first. A count other than six or an octet over 255 is refused.

fn octets

fn octets(): List<Int>

The six octets, most significant first.

fn show

fn show(): String

3c:22:fb:0a:1b:9e.

fn tryFrom

static fn tryFrom(text: String): Result<Self, AddressError>

Six groups of two hexadecimal digits, either case, with one separator throughout: : (3c:22:fb:0a:1b:9e) or - (3C-22-FB-0A-1B-9E, how Windows writes it).