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

compatibility with old roscpp using dxr/quick-xml fix #8

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ keywords = ["ros", "rosrust", "roscore", "robotics"]
categories = ["science::robotics"]

[dependencies]
dxr = { version = "0.6.3" }
dxr_server = { version = "0.6.3", features = ["axum", "multicall"] }
dxr_client = { version = "0.6.3", default-features = false, features = [
dxr = { version = "0.7.0" }
dxr_server = { version = "0.7.0", features = ["axum", "multicall"] }
dxr_client = { version = "0.7.0", default-features = false, features = [
"reqwest",
"rustls-tls" # Use rustls instead of openssl for easier cross-compilation
] }
Expand Down
12 changes: 5 additions & 7 deletions src/client_api.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use dxr::Value;
use dxr_client::{Call, Client, ClientBuilder, Url};
use dxr_client::{Client, ClientBuilder, Url};

pub struct ClientApi {
client: Client,
Expand Down Expand Up @@ -41,8 +41,8 @@ impl ClientApi {
topic: &str,
publisher_apis: &Vec<String>,
) -> anyhow::Result<Value> {
let request = Call::new("publisherUpdate", (caller_id, topic, publisher_apis));
let result = self.client.call::<_, _>(request).await;
let result = self.client.call::<_, _>("publisherUpdate", (caller_id, topic, publisher_apis)).await;

Ok(result?)
}

Expand All @@ -63,8 +63,7 @@ impl ClientApi {
key: &str,
value: &Value,
) -> anyhow::Result<Value> {
let request = Call::new("paramUpdate", (caller_id, key, value));
let result = self.client.call(request).await;
let result = self.client.call("paramUpdate", (caller_id, key, value)).await;
Ok(result?)
}

Expand All @@ -84,8 +83,7 @@ impl ClientApi {
caller_id: &str,
reason: &str,
) -> anyhow::Result<()> {
let request = Call::new("shutdown", (caller_id, reason));
let result = self.client.call(request).await;
let result = self.client.call("shutdown", (caller_id, reason)).await;
Ok(result?)
}
}
10 changes: 5 additions & 5 deletions src/core.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extern crate dxr;
use dxr_client::{Call, Client, ClientBuilder, Url};
use dxr_client::{Client, ClientBuilder, Url};
use maplit::hashmap;
use paste::paste;
use std::collections::hash_map::Entry;
Expand Down Expand Up @@ -1011,8 +1011,8 @@ impl Handler for GetParamHandler {
let key_path = key_full.strip_prefix('/').unwrap_or(&key_full).split('/');

Ok(match params.get(key_path) {
Some(value) => (1, "".to_owned(), value.to_owned()),
None => (-1, format!("Parameter [{key_full}] is not set"), Value::i4(0)),
Some(value) => (1, format!("Parameter [{}]", &key_full), value.to_owned()),
Copy link
Owner

@PatWie PatWie Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we for consistency keep the formatting string the same as below or adjust the line below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, fixed.

None => (-1, format!("Parameter [{}] is not set", &key_full), Value::i4(0)),
}
.try_to_value()?)
}
Expand Down Expand Up @@ -1423,11 +1423,11 @@ macro_rules! implement_client_fn {
($name:ident($($v:ident: $t:ty),*)->$response_type:ident) => {
paste!{
pub async fn [<$name:snake>](&self, $($v: $t),*) -> anyhow::Result<$response_type>{
let request = Call::new(
let request = (
MasterEndpoints::$name.as_str(),
($($v,)*),
);
let response = self.client.call(request).await?;
let response = self.client.call(request.0, request.1).await?;
let value = $response_type::try_from_value(&response)?;
Ok(value)
}
Expand Down
Loading