From 914f50143098baee3145d23ee9dddf6990e6d8b9 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Mon, 8 May 2023 12:56:55 -0300 Subject: [PATCH] Update plugins/os/src/lib.rs Co-authored-by: Fabian-Lars --- plugins/os/src/lib.rs | 66 ++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 42 deletions(-) diff --git a/plugins/os/src/lib.rs b/plugins/os/src/lib.rs index 7ed9dfbf..96ebee7c 100644 --- a/plugins/os/src/lib.rs +++ b/plugins/os/src/lib.rs @@ -12,8 +12,6 @@ mod error; pub use error::Error; type Result = std::result::Result; -pub struct OperatingSystem(AppHandle); - pub enum Kind { Linux, Windows, @@ -34,49 +32,37 @@ impl Display for Kind { } } -impl OperatingSystem { - pub fn platform(&self) -> &'static str { - match std::env::consts::OS { - "windows" => "win32", - "macos" => "darwin", - _ => std::env::consts::OS, - } - } - - pub fn version(&self) -> Version { - os_info::get().version().clone() - } - - pub fn kind(&self) -> Kind { - #[cfg(target_os = "linux")] - return Kind::Linux; - #[cfg(target_os = "windows")] - return Kind::Windows; - #[cfg(target_os = "macos")] - return Kind::Darwin; - #[cfg(target_os = "ios")] - return Kind::IOS; - #[cfg(target_os = "android")] - return Kind::Android; +pub fn platform() -> &'static str { + match std::env::consts::OS { + "windows" => "win32", + "macos" => "darwin", + _ => std::env::consts::OS, } +} - pub fn arch(&self) -> &'static str { - std::env::consts::ARCH - } +pub fn version() -> Version { + os_info::get().version().clone() +} - pub fn tempdir(&self) -> PathBuf { - std::env::temp_dir() - } +pub fn kind() -> Kind { + #[cfg(target_os = "linux")] + return Kind::Linux; + #[cfg(target_os = "windows")] + return Kind::Windows; + #[cfg(target_os = "macos")] + return Kind::Darwin; + #[cfg(target_os = "ios")] + return Kind::IOS; + #[cfg(target_os = "android")] + return Kind::Android; } -pub trait OperatingSystemExt { - fn os(&self) -> &OperatingSystem; +pub fn arch() -> &'static str { + std::env::consts::ARCH } -impl> OperatingSystemExt for T { - fn os(&self) -> &OperatingSystem { - self.state::>().inner() - } +pub fn tempdir() -> PathBuf { + std::env::temp_dir() } pub fn init() -> TauriPlugin { @@ -88,9 +74,5 @@ pub fn init() -> TauriPlugin { commands::arch, commands::tempdir ]) - .setup(|app, _api| { - app.manage(OperatingSystem(app.clone())); - Ok(()) - }) .build() }