cobble_core/minecraft/models/
library_natives.rs

1use crate::utils::Platform;
2use serde::{Deserialize, Serialize};
3
4/// Information about available native library.
5#[derive(Clone, Debug, Deserialize, Serialize)]
6pub struct LibraryNatives {
7    /// Linux native name.
8    pub linux: Option<String>,
9    /// Windows native name.
10    pub windows: Option<String>,
11    /// MacOs native name
12    pub osx: Option<String>,
13}
14
15impl LibraryNatives {
16    /// Gets the current platforms native.
17    ///
18    /// Returns none when the platform is not supported/implemented.
19    /// Currently linux, windows and macos are supported.
20    pub fn get_for_current_platform(&self) -> Option<String> {
21        let current = Platform::current();
22
23        match current {
24            Platform::Linux => self.linux.clone(),
25            Platform::Windows => self.windows.clone(),
26            Platform::MacOs => self.osx.clone(),
27            Platform::Other => None,
28        }
29    }
30}