Skip to content

Commit

Permalink
Fix some shenanigans
Browse files Browse the repository at this point in the history
  • Loading branch information
carter committed Dec 2, 2024
1 parent 9150633 commit 533d21f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
6 changes: 3 additions & 3 deletions roslibrust/examples/generic_client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! Purpose of this example is to show how the TopicProvider trait can be use
//! to create code that is generic of which communication backend it will use.
use roslibrust::topic_provider::*;

roslibrust_codegen_macro::find_and_generate_ros_messages!("assets/ros1_common_interfaces/std_msgs");

#[cfg(feature = "topic_provider")]
#[tokio::main]
Expand All @@ -10,9 +13,6 @@ async fn main() {
.init()
.unwrap();

use roslibrust::topic_provider::*;

roslibrust_codegen_macro::find_and_generate_ros_messages!("assets/ros1_common_interfaces");
// TopicProvider cannot be an "Object Safe Trait" due to its generic parameters
// This means we can't do:

Expand Down
6 changes: 3 additions & 3 deletions roslibrust/examples/generic_client_services.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! Purpose of this example is to show how the ServiceProvider trait can be use
//! to create code that is generic of which communication backend it will use.
use roslibrust::topic_provider::*;

roslibrust_codegen_macro::find_and_generate_ros_messages!("assets/ros1_common_interfaces");

#[cfg(feature = "topic_provider")]
#[tokio::main]
Expand All @@ -10,9 +13,6 @@ async fn main() {
.init()
.unwrap();

use roslibrust::topic_provider::*;

roslibrust_codegen_macro::find_and_generate_ros_messages!("assets/ros1_common_interfaces");
// TopicProvider cannot be an "Object Safe Trait" due to its generic parameters
// This means we can't do:

Expand Down
6 changes: 3 additions & 3 deletions roslibrust_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ pub fn generate_rust_ros_message_definitions(
}
Ok(())
})
.collect::<Result<_, Error>>()?;
.collect::<Result<(), Error>>()?;
// Do the same for services
services
.into_iter()
Expand All @@ -744,7 +744,7 @@ pub fn generate_rust_ros_message_definitions(
}
Ok(())
})
.collect::<Result<_, Error>>()?;
.collect::<Result<(), Error>>()?;
// Now generate modules to wrap all of the TokenStreams in a module for each package
let all_pkgs = modules_to_struct_definitions
.keys()
Expand All @@ -753,7 +753,7 @@ pub fn generate_rust_ros_message_definitions(
let module_definitions = modules_to_struct_definitions
.into_iter()
.map(|(pkg, struct_defs)| generate_mod(pkg, struct_defs, &all_pkgs[..]))
.collect::<Vec<_>>();
.collect::<Vec<TokenStream>>();

Ok(quote! {
#(#module_definitions)*
Expand Down
14 changes: 12 additions & 2 deletions roslibrust_zenoh/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! A crate for interfacing to ROS1 via the [zenoh-ros1-plugin / zenoh-ros1-bridge](https://github.com/eclipse-zenoh/zenoh-plugin-ros1).
use roslibrust::topic_provider::{Publish, ServiceProvider, Subscribe, TopicProvider};
use roslibrust::topic_provider::{Publish, Service, ServiceProvider, Subscribe, TopicProvider};
use roslibrust::{RosLibRustError, RosLibRustResult};
use roslibrust_codegen::{RosMessageType, RosServiceType};

Expand Down Expand Up @@ -135,8 +135,18 @@ fn mangle_topic(topic: &str, type_str: &str, md5sum: &str) -> String {
format!("{type_str}/{md5sum}/{topic}")
}

pub struct ZenohServiceClient<T: RosServiceType> {
_marker: std::marker::PhantomData<T>,
}

impl<T: RosServiceType> Service<T> for ZenohServiceClient<T> {
async fn call(&self, request: &T::Request) -> RosLibRustResult<T::Response> {
todo!()
}
}

impl ServiceProvider for ZenohClient {
type ServiceClient<T: RosServiceType> = ();
type ServiceClient<T: RosServiceType> = ZenohServiceClient<T>;
type ServiceServer = ();

async fn service_client<T: roslibrust_codegen::RosServiceType + 'static>(
Expand Down

0 comments on commit 533d21f

Please sign in to comment.