1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
use anyhow::Result; #[derive(Debug)] pub struct Windows { pub version: String, } impl Windows { #[cfg(target_os = "windows")] pub fn detect() -> Result<Windows> { use crate::winapi; let version = winapi::version_info()?; let version = winapi::edition(&version); Ok(Windows { version }) } #[cfg(not(target_os = "windows"))] pub fn detect() -> Result<Windows> { unreachable!() } } impl ToString for Windows { fn to_string(&self) -> String { format!("windows {}", self.version) } }