Skip to main content

zond_engine/network/
mac.rs

1// Copyright (c) 2026 Erik Lening (hollowpointer) and Contributors
2//
3// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4// If a copy of the MPL was not distributed with this file, You can obtain one at
5// https://mozilla.org/MPL/2.0/.
6
7//! Extensions for MAC address conversions between pnet and the core domain model.
8
9use crate::core::models::mac::MacAddr as CoreMacAddr;
10use pnet::util::MacAddr as PnetMacAddr;
11
12/// An extension trait to seamlessly convert from `pnet::util::MacAddr` to the
13/// native `crate::core::models::mac::MacAddr`.
14pub trait IntoCoreMac {
15    fn into_core(self) -> CoreMacAddr;
16}
17
18impl IntoCoreMac for PnetMacAddr {
19    #[inline]
20    fn into_core(self) -> CoreMacAddr {
21        CoreMacAddr::new(self.0, self.1, self.2, self.3, self.4, self.5)
22    }
23}