darra-ethercat-master 0.5.0

Darra EtherCAT Master SDK - Rust 绑定 (封装 Darra.Core.dll/libDarraCore.so)
Documentation
//! 静态工具函数 - 其他
//!
//! 对应 C# Static/Other.cs
//! 包含日志初始化、管理员权限检测等功能。

use crate::utils::ffi;

/// 检测管理员权限(仅 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)
    }
}