pub struct InterfaceSnapshot {
pub name: String,
pub is_up: bool,
pub is_loopback: bool,
pub is_multicast: bool,
pub is_broadcast: bool,
pub mac_address: Option<String>,
pub interface_index: Option<u32>,
pub ip_addresses: Vec<IpAddr>,
pub subnet_mask: Option<IpAddr>,
pub gateway: Option<IpAddr>,
}
Expand description
Represents a snapshot of a network interface
Fields§
§name: String
§is_up: bool
§is_loopback: bool
§is_multicast: bool
§is_broadcast: bool
§mac_address: Option<String>
§interface_index: Option<u32>
§ip_addresses: Vec<IpAddr>
§subnet_mask: Option<IpAddr>
§gateway: Option<IpAddr>
Implementations§
Source§impl InterfaceSnapshot
impl InterfaceSnapshot
Sourcepub fn serialize_snapshot(
snapshot: &Vec<InterfaceSnapshot>,
) -> Result<Vec<u8>, Error>
pub fn serialize_snapshot( snapshot: &Vec<InterfaceSnapshot>, ) -> Result<Vec<u8>, Error>
Sourcepub fn deserialize_snapshot(
data: &[u8],
) -> Result<Vec<InterfaceSnapshot>, Error>
pub fn deserialize_snapshot( data: &[u8], ) -> Result<Vec<InterfaceSnapshot>, Error>
Sourcepub fn take_all() -> Vec<InterfaceSnapshot>
pub fn take_all() -> Vec<InterfaceSnapshot>
Captures the current state of all network interfaces available on the system.
- Retrieves interface names, statuses, MAC addresses, and other properties using
pnet::datalink
. - Fetches assigned IP addresses and subnet masks using
get_if_addrs
.
§Returns
- A
Vec<InterfaceSnapshot>
containing details of all detected network interfaces.
Trait Implementations§
Source§impl Debug for InterfaceSnapshot
impl Debug for InterfaceSnapshot
Source§impl<'de> Deserialize<'de> for InterfaceSnapshot
impl<'de> Deserialize<'de> for InterfaceSnapshot
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for InterfaceSnapshot
impl PartialEq for InterfaceSnapshot
Source§impl Serialize for InterfaceSnapshot
impl Serialize for InterfaceSnapshot
impl StructuralPartialEq for InterfaceSnapshot
Auto Trait Implementations§
impl Freeze for InterfaceSnapshot
impl RefUnwindSafe for InterfaceSnapshot
impl Send for InterfaceSnapshot
impl Sync for InterfaceSnapshot
impl Unpin for InterfaceSnapshot
impl UnwindSafe for InterfaceSnapshot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more