Skip to content

Commit

Permalink
compatibility with old roscpp using dxr/quick-xml fix (#8)
Browse files Browse the repository at this point in the history
* compatibility with old roscpp using dxr/quick-xml fix

* remove crates.io patch section

* make string formatting consistent
  • Loading branch information
jobafr authored Dec 3, 2024
1 parent cb029d1 commit e2eef4a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
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()),
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

0 comments on commit e2eef4a

Please sign in to comment.