Move browser code to core crate

This commit is contained in:
John Doty 2022-12-17 08:48:57 -08:00
parent 9cf0089e48
commit d6c9ae8d71
5 changed files with 32 additions and 15 deletions

34
src/browse/mod.rs Normal file
View file

@ -0,0 +1,34 @@
use crate::message::Message;
use anyhow::Result;
use tokio::sync::mpsc;
#[cfg(target_family = "unix")]
mod browse_unix;
#[cfg(target_family = "unix")]
use browse_unix::{browse_url_impl, handle_browser_open_impl};
#[inline]
pub async fn browse_url(url: &String) {
browse_url_impl(url).await
}
#[cfg(not(target_family = "unix"))]
pub async fn browse_url_impl(url: &String) {
print!("Opening a browser is not supported on this platform\n");
std::process::exit(1);
}
#[inline]
pub async fn handle_browser_open(
messages: mpsc::Sender<Message>,
) -> Result<()> {
handle_browser_open_impl(messages).await
}
#[cfg(not(target_family = "unix"))]
async fn handle_browser_open_impl(
messages: mpsc::Sender<Message>,
) -> Result<()> {
std::future::pending().await
}