darra-ethercat-master 2.0.6

商业 EtherCAT 主站协议栈 · 实时内核驱动 · 抖动 1µs · Windows + Linux · 多编程语言 · 全协议 · 支持复杂拓扑 + 热插拔 · ethercat.darra.xyz · Commercial EtherCAT Master protocol stack · Real-time kernel driver · 1µs jitter · Multi-platform · Multi-language · Complex topology + hot-plug.
//! 静态工具函数 - 其他
//!
//! 对应 C# Static/Other.cs
//! 包含日志初始化、管理员权限检测等功能。

/// 检测管理员权限(仅 Windows)
///
/// 对应 C# AdminHelper.IsRunningAsAdmin()
#[cfg(target_os = "windows")]
pub fn is_running_as_admin() -> bool {
    // Rust 层面无法直接检测,委托给 DLL 或使用系统 API
    // 此处提供存根实现
    false
}

#[cfg(not(target_os = "windows"))]
pub fn is_running_as_admin() -> bool {
    // Linux: 检查 euid == 0
    unsafe { libc::geteuid() == 0 }
}

/// 获取真实的系统版本字符串
pub fn get_system_version() -> String {
    #[cfg(target_os = "windows")]
    {
        // Windows: 返回 OS 版本
        format!("Windows {}", std::env::consts::ARCH)
    }
    #[cfg(not(target_os = "windows"))]
    {
        format!("Linux {}", std::env::consts::ARCH)
    }
}