diff --git a/src/bin/busd.rs b/src/bin/busd.rs index 5aee66e..bca2a9a 100644 --- a/src/bin/busd.rs +++ b/src/bin/busd.rs @@ -71,7 +71,7 @@ async fn main() -> Result<()> { Address::try_from(bus_type)? }; - let mut bus = bus::Bus::for_address(Some(&format!("{address}"))).await?; + let mut bus = bus::Bus::for_address(&format!("{address}")).await?; #[cfg(unix)] if let Some(fd) = args.ready_fd { diff --git a/src/bus/mod.rs b/src/bus/mod.rs index fc686dd..958f725 100644 --- a/src/bus/mod.rs +++ b/src/bus/mod.rs @@ -1,6 +1,4 @@ use anyhow::{bail, Ok, Result}; -#[cfg(unix)] -use std::{env, path::Path}; use std::{str::FromStr, sync::Arc}; #[cfg(unix)] use tokio::fs::remove_file; @@ -45,11 +43,8 @@ enum Listener { } impl Bus { - pub async fn for_address(address: Option<&str>) -> Result { - let mut address = match address { - Some(address) => Address::from_str(address)?, - None => Address::from_str(&default_address())?, - }; + pub async fn for_address(address: &str) -> Result { + let mut address = Address::from_str(address)?; let guid: OwnedGuid = match address.guid() { Some(guid) => guid.to_owned().into(), None => { @@ -246,23 +241,3 @@ impl Bus { self.inner.next_id } } - -#[cfg(unix)] -fn default_address() -> String { - let runtime_dir = env::var("XDG_RUNTIME_DIR") - .as_ref() - .map(|s| Path::new(s).to_path_buf()) - .ok() - .unwrap_or_else(|| { - Path::new("/run") - .join("user") - .join(format!("{}", nix::unistd::Uid::current())) - }); - - format!("unix:dir={}", runtime_dir.display()) -} - -#[cfg(not(unix))] -fn default_address() -> String { - "tcp:host=127.0.0.1,port=4242".to_string() -} diff --git a/tests/fdo.rs b/tests/fdo.rs index 332b44c..55542d4 100644 --- a/tests/fdo.rs +++ b/tests/fdo.rs @@ -40,7 +40,7 @@ async fn name_ownership_changes() { } async fn name_ownership_changes_(address: &str) { - let mut bus = Bus::for_address(Some(address)).await.unwrap(); + let mut bus = Bus::for_address(address).await.unwrap(); let (tx, rx) = tokio::sync::oneshot::channel(); let handle = tokio::spawn(async move { diff --git a/tests/greet.rs b/tests/greet.rs index 777ecc2..02718b3 100644 --- a/tests/greet.rs +++ b/tests/greet.rs @@ -45,7 +45,7 @@ async fn greet() { } async fn greet_(socket_addr: &str) { - let mut bus = Bus::for_address(Some(socket_addr)).await.unwrap(); + let mut bus = Bus::for_address(socket_addr).await.unwrap(); let (tx, mut rx) = channel(1); let handle = tokio::spawn(async move { diff --git a/tests/monitor.rs b/tests/monitor.rs index 5169a9c..1a5a96e 100644 --- a/tests/monitor.rs +++ b/tests/monitor.rs @@ -20,7 +20,7 @@ async fn become_monitor() { busd::tracing_subscriber::init(); let address = "tcp:host=127.0.0.1,port=4242".to_string(); - let mut bus = Bus::for_address(Some(&address)).await.unwrap(); + let mut bus = Bus::for_address(&address).await.unwrap(); let (tx, rx) = tokio::sync::oneshot::channel(); let handle = tokio::spawn(async move { diff --git a/tests/multiple_conns.rs b/tests/multiple_conns.rs index 4125c96..78a3386 100644 --- a/tests/multiple_conns.rs +++ b/tests/multiple_conns.rs @@ -33,7 +33,7 @@ async fn multi_conenct() { } async fn multi_conenct_(socket_addr: &str) { - let mut bus = Bus::for_address(Some(socket_addr)).await.unwrap(); + let mut bus = Bus::for_address(socket_addr).await.unwrap(); let (tx, rx) = channel(); let handle = tokio::spawn(async move {