darra-ethercat-master 2.3.0

Commercial EtherCAT master protocol stack, real-time kernel driver integration, Windows and Linux support, multi-language SDKs, complex topology and hot-plug support.
Documentation
//! 静态工具函数 - 其他
//!
//! 对应 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)
    }
}