Expand description
§use-mac
use-mac provides small helpers for parsing, formatting, and normalizing MAC addresses.
Experimental: this crate is below 0.3.0 and the API may change.
§Example Usage
use use_mac::{normalize_mac, parse_mac_address};
let mac = parse_mac_address("00-1A-2B-3C-4D-5E").unwrap();
assert_eq!(normalize_mac("001A2B3C4D5E"), Some("00:1A:2B:3C:4D:5E".to_string()));
assert_eq!(mac.octets, [0x00, 0x1A, 0x2B, 0x3C, 0x4D, 0x5E]);§Scope
- Parsing common MAC address formats.
- Formatting helpers for colon and hyphen output.
- Small helpers for broadcast and zero-address checks.
§Non-goals
- Vendor lookup.
- Network adapter inspection.
- Packet parsing.
§License
Licensed under MIT OR Apache-2.0.
Structs§
- MacAddress
- Stores a parsed MAC address.
Functions§
- format_
mac_ colon - Formats a MAC address using colon separators.
- format_
mac_ hyphen - Formats a MAC address using hyphen separators.
- is_
broadcast_ mac - Returns
truewhen the MAC address is the all-ones broadcast address. - is_
mac_ address - Returns
truewhen the input is a valid MAC address in a supported format. - is_
zero_ mac - Returns
truewhen the MAC address is the all-zero address. - normalize_
mac - Normalizes a MAC address to uppercase colon-separated form.
- parse_
mac_ address - Parses a MAC address from a common textual format.