Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix connection breakage #1036

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>)>;