1#[repr(transparent)]
2#[derive(Default, PartialEq, Eq, Copy, Clone)]
3pub struct OUI(pub [u8; OUI::SIZE]);
4impl OUI {
5 pub const SIZE: usize = 3;
6 pub const QUALCOMM: OUI = OUI([0x00, 0xb0, 0x52]); pub const BROADCOM: OUI = OUI([0x00, 0x1f, 0x84]); pub const ST: OUI = OUI([0x00, 0x80, 0xe1]); pub fn name(&self) -> Option<&'static str> {
11 Some(match *self {
12 OUI::QUALCOMM => "Qualcomm",
13 OUI::BROADCOM => "Broadcom",
14 OUI::ST => "ST",
15 _ => return None,
16 })
17 }
18}
19impl core::ops::Deref for OUI {
20 type Target = [u8; OUI::SIZE];
21 fn deref(&self) -> &Self::Target {
22 &self.0
23 }
24}
25impl core::fmt::Debug for OUI {
26 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
27 if let Some(name) = self.name() {
28 write!(f, "{}", name)
29 } else {
30 write!(
31 f,
32 "Unknown({:02x}:{:02x}:{:02x})",
33 self[0], self[1], self[2]
34 )
35 }
36 }
37}