fret_platform_native/
open_url.rs1use fret_platform::open_url::{OpenUrl, OpenUrlError, OpenUrlErrorKind};
2
3#[derive(Debug, Default)]
4pub struct NativeOpenUrl;
5
6pub type DesktopOpenUrl = NativeOpenUrl;
7
8impl OpenUrl for NativeOpenUrl {
9 fn open_url(&mut self, url: &str) -> Result<(), OpenUrlError> {
10 #[cfg(all(
11 not(target_arch = "wasm32"),
12 any(target_os = "windows", target_os = "macos", target_os = "linux")
13 ))]
14 {
15 webbrowser::open(url).map_err(|_| OpenUrlError {
16 kind: OpenUrlErrorKind::BackendError,
17 })?;
18 Ok(())
19 }
20
21 #[cfg(not(all(
22 not(target_arch = "wasm32"),
23 any(target_os = "windows", target_os = "macos", target_os = "linux")
24 )))]
25 {
26 let _ = url;
27 Err(OpenUrlError {
28 kind: OpenUrlErrorKind::Unsupported,
29 })
30 }
31 }
32}