hw_crossplatform/
lib.rs

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
30
31
32
33
34
35
use std::env::consts::FAMILY;
use crate::enums::SystemFamily;
use crate::strategy::traits::HwStrategy;

pub mod strategy;
pub mod enums;
pub mod dtos;

/// Returns the system family based on the operating system.
///
/// # Purpose
///
/// This function determines the system family (Windows, MacOSX, Linux) based on the operating system family constant.
///
/// # Parameters
///
/// None. The function does not take any parameters.
///
/// # Return Value
///
/// - `Ok(SystemFamily::Windows)`: If the operating system family is "windows".
/// - `Ok(SystemFamily::Macosx)`: If the operating system family is "macosx".
/// - `Ok(SystemFamily::Linux)`: If the operating system family is "unix".
/// - `Err("Unknown operating system family")`: If the operating system family is not recognized.
pub fn get_system_family<'a>() -> Result<SystemFamily, &'a str> {
	match FAMILY {
		"windows" => Ok(SystemFamily::Windows),

		"macosx" => Ok(SystemFamily::Macosx),

		"unix" => Ok(SystemFamily::Linux),

		_ => Err("Unknown operating system family")
	}
}