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