Skip to content

Commit

Permalink
Merge pull request #1036 from zeenix/fix-connection-breakage
Browse files Browse the repository at this point in the history
Fix connection breakage
  • Loading branch information
zeenix authored Oct 2, 2024
2 parents 1ec30f0 + cd799e4 commit 2470aed
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions zbus/src/connection/connect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,26 @@ use super::socket::{self, BoxedSplit};
mod macos;
mod win32;

type ConnectResult = Result<(BoxedSplit, Option<OwnedGuid>)>;
pub(crate) async fn connect_address(
address: &[Address<'_>],
) -> Result<(BoxedSplit, Option<OwnedGuid>)> {
for addr in address {
match connect(addr).await {
Ok(res) => {
return Ok(res);
}
Err(e) => {
debug!("Failed to connect to: {}", e);
continue;
}
}
}
Err(Error::Address("No connectable address".into()))
}

fn connect(addr: &Address<'_>) -> Pin<Box<dyn Future<Output = ConnectResult>>> {
fn connect(
addr: &Address<'_>,
) -> Pin<Box<dyn Future<Output = ConnectResult> + Send + Sync + 'static>> {
let addr = addr.to_owned();
Box::pin(async move {
let guid = match addr.guid() {
Expand Down Expand Up @@ -44,19 +61,4 @@ fn connect(addr: &Address<'_>) -> Pin<Box<dyn Future<Output = ConnectResult>>> {
})
}

pub(crate) async fn connect_address(
address: &[Address<'_>],
) -> Result<(BoxedSplit, Option<OwnedGuid>)> {
for addr in address {
match connect(addr).await {
Ok(res) => {
return Ok(res);
}
Err(e) => {
debug!("Failed to connect to: {}", e);
continue;
}
}
}
Err(Error::Address("No connectable address".into()))
}
type ConnectResult = Result<(BoxedSplit, Option<OwnedGuid>)>;

0 comments on commit 2470aed

Please sign in to comment.