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