Returns bool indicating whether the URL was opened successfully
(url: impl AsRef<str>)
| 71 | |
| 72 | /// Returns bool indicating whether the URL was opened successfully |
| 73 | pub async fn open_url_async(url: impl AsRef<str>) -> Result<(), Error> { |
| 74 | cfg_if! { |
| 75 | if #[cfg(target_os = "macos")] { |
| 76 | open_macos(url) |
| 77 | } else { |
| 78 | match tokio::process::Command::from(open_command(url)).output().await { |
| 79 | Ok(output) => { |
| 80 | tracing::trace!(?output, "open_url_async output"); |
| 81 | if output.status.success() { |
| 82 | Ok(()) |
| 83 | } else { |
| 84 | Err(Error::Failed) |
| 85 | } |
| 86 | }, |
| 87 | Err(err) => Err(err.into()), |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | #[cfg(test)] |
| 94 | mod tests { |
no outgoing calls