scirs2_core/resource/
network.rs

1//! # Network Detection and Capabilities
2//!
3//! This module provides network interface detection for I/O optimization.
4
5use crate::error::CoreResult;
6
7/// Network interface information
8#[derive(Debug, Clone)]
9pub struct NetworkInfo {
10    /// Network interfaces
11    pub interfaces: Vec<NetworkInterface>,
12    /// Maximum transmission unit
13    pub mtu: usize,
14    /// Network bandwidth estimate (Mbps)
15    pub bandwidth_mbps: f64,
16    /// Network latency estimate (milliseconds)
17    pub latency_ms: f64,
18}
19
20impl Default for NetworkInfo {
21    fn default() -> Self {
22        Self {
23            interfaces: vec![NetworkInterface::default()],
24            mtu: 1500,
25            bandwidth_mbps: 1000.0, // 1 Gbps default
26            latency_ms: 1.0,
27        }
28    }
29}
30
31impl NetworkInfo {
32    /// Detect network information
33    pub fn detect() -> CoreResult<Self> {
34        // Simplified implementation
35        Ok(Self::default())
36    }
37}
38
39/// Network interface information
40#[derive(Debug, Clone)]
41pub struct NetworkInterface {
42    /// Interface name
43    pub name: String,
44    /// Interface type
45    pub interface_type: NetworkInterfaceType,
46    /// MAC address
47    pub mac_address: String,
48    /// IP addresses
49    pub ip_addresses: Vec<String>,
50    /// Interface status
51    pub is_up: bool,
52}
53
54impl Default for NetworkInterface {
55    fn default() -> Self {
56        Self {
57            name: "eth0".to_string(),
58            interface_type: NetworkInterfaceType::Ethernet,
59            mac_address: "00:00:00:00:00:00".to_string(),
60            ip_addresses: vec!["127.0.0.1".to_string()],
61            is_up: true,
62        }
63    }
64}
65
66/// Network interface types
67#[derive(Debug, Clone, Copy, PartialEq, Eq)]
68pub enum NetworkInterfaceType {
69    /// Ethernet
70    Ethernet,
71    /// WiFi
72    WiFi,
73    /// Loopback
74    Loopback,
75    /// Infiniband
76    Infiniband,
77    /// Unknown
78    Unknown,
79}