abletk/src/platform.rs

39 lines
1.3 KiB
Rust
Executable File

/*
* Copyright (C) 2022 Umut İnan Erdoğan <umutinanerdogan@pm.me>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#[cfg(target_os = "windows")] const TARGET_PLATFORM: Platform = Platform::Windows;
#[cfg(target_os = "linux")] const TARGET_PLATFORM: Platform = Platform::Linux;
#[cfg(target_os = "macos")] const TARGET_PLATFORM: Platform = Platform::MacOS;
#[cfg(not(any(
target_os = "windows",
target_os = "linux",
target_os = "macos",
)))]
const TARGET_PLATFORM: Platform = Platform::Unknown;
#[non_exhaustive]
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
/// An enum of operating systems that are supported by AbleTK. This does not
/// correspond to backends used by AbleTK, and is to be used by applications
/// that have platform-dependent behaviour.
// Contributors: name these according to their marketing names, including
// capitalisation, only changing the first letter to an upper
// case letter. E.g. Windows not Win32, MacOS not MacOs or macOS.
pub enum Platform {
Windows,
Linux,
MacOS,
Unknown
}
impl Platform {
pub const fn target() -> Self {
TARGET_PLATFORM
}
}