diff --git a/Cargo.lock b/Cargo.lock index 13ab4fb2..46cd13aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2588,6 +2588,7 @@ dependencies = [ "eyre", "futures", "pyo3", + "pyo3_special_method_derive", "serde", "serde_assert", ] @@ -6556,9 +6557,9 @@ dependencies = [ [[package]] name = "pyo3_special_method_derive" -version = "0.1.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba8f52c03a4a510534a6cea6a44e3872a7287392e7c9b8ffe9a9409d736f10a" +checksum = "e831c9f620de245243f105f2d764c59c32a853bd1c9fb34504116e0d6d094fad" dependencies = [ "proc-macro2", "pyo3", diff --git a/apis/python/node/Cargo.toml b/apis/python/node/Cargo.toml index a51e0857..7d5cac89 100644 --- a/apis/python/node/Cargo.toml +++ b/apis/python/node/Cargo.toml @@ -25,7 +25,7 @@ arrow = { workspace = true, features = ["pyarrow"] } pythonize = { workspace = true } futures = "0.3.28" dora-ros2-bridge-python = { workspace = true } -pyo3_special_method_derive = "0.1.0" +pyo3_special_method_derive = "0.2.1" [lib] name = "dora" diff --git a/apis/python/node/src/lib.rs b/apis/python/node/src/lib.rs index d738d72e..00693d71 100644 --- a/apis/python/node/src/lib.rs +++ b/apis/python/node/src/lib.rs @@ -11,7 +11,7 @@ use eyre::Context; use futures::{Stream, StreamExt}; use pyo3::prelude::*; use pyo3::types::{PyBytes, PyDict}; -use pyo3_special_method_derive::DirHelper; +use pyo3_special_method_derive::Dir; /// The custom node API lets you integrate `dora` into your application. /// It allows you to retrieve input and send output in any fashion you want. @@ -25,7 +25,7 @@ use pyo3_special_method_derive::DirHelper; /// ``` /// #[pyclass] -#[derive(DirHelper)] +#[derive(Dir)] pub struct Node { events: Events, pub node: DoraNode, diff --git a/libraries/extensions/ros2-bridge/python/Cargo.toml b/libraries/extensions/ros2-bridge/python/Cargo.toml index fd1b8627..92bcad08 100644 --- a/libraries/extensions/ros2-bridge/python/Cargo.toml +++ b/libraries/extensions/ros2-bridge/python/Cargo.toml @@ -12,6 +12,7 @@ eyre = "0.6" serde = "1.0.166" arrow = { workspace = true, features = ["pyarrow"] } futures = "0.3.28" +pyo3_special_method_derive = "0.2.1" [dev-dependencies] serde_assert = "0.7.1" diff --git a/libraries/extensions/ros2-bridge/python/src/lib.rs b/libraries/extensions/ros2-bridge/python/src/lib.rs index ee7f6830..7819cfaa 100644 --- a/libraries/extensions/ros2-bridge/python/src/lib.rs +++ b/libraries/extensions/ros2-bridge/python/src/lib.rs @@ -18,6 +18,7 @@ use pyo3::{ types::{PyAnyMethods, PyDict, PyList, PyModule, PyModuleMethods}, Bound, PyAny, PyObject, PyResult, Python, }; +use pyo3_special_method_derive::{Dict, Dir, Repr, Str}; use typed::{deserialize::StructDeserializer, TypeInfo, TypedValue}; pub mod qos; @@ -45,6 +46,7 @@ pub mod typed; /// :type ros_paths: typing.List[str], optional /// #[pyclass] +#[derive(Str, Repr, Dir, Dict)] pub struct Ros2Context { context: ros2_client::Context, messages: Arc>>, @@ -147,6 +149,7 @@ impl Ros2Context { /// See: https://github.com/jhelovuo/ros2-client/issues/4 /// #[pyclass] +#[derive(Str, Repr, Dir, Dict)] pub struct Ros2Node { node: ros2_client::Node, messages: Arc>>, @@ -251,7 +254,7 @@ impl Ros2Node { /// ROS2 Node Options /// :type rosout: bool, optional /// -#[derive(Debug, Clone, Default)] +#[derive(Clone, Default, Str, Repr, Dir, Dict)] #[pyclass] #[non_exhaustive] pub struct Ros2NodeOptions { @@ -281,6 +284,7 @@ impl From for ros2_client::NodeOptions { /// - dora Ros2 bridge functionality is considered **unstable**. It may be changed /// at any point without it being considered a breaking change. #[pyclass] +#[derive(Str, Repr, Dir, Dict)] #[non_exhaustive] pub struct Ros2Topic { topic: rustdds::Topic, @@ -293,6 +297,7 @@ pub struct Ros2Topic { /// - dora Ros2 bridge functionality is considered **unstable**. It may be changed /// at any point without it being considered a breaking change. #[pyclass] +#[derive(Str, Repr, Dir, Dict)] #[non_exhaustive] pub struct Ros2Publisher { publisher: ros2_client::Publisher>, @@ -363,6 +368,7 @@ impl Ros2Publisher { /// - dora Ros2 bridge functionality is considered **unstable**. It may be changed /// at any point without it being considered a breaking change. #[pyclass] +#[derive(Str, Repr, Dir, Dict)] #[non_exhaustive] pub struct Ros2Subscription { deserializer: StructDeserializer<'static>, diff --git a/libraries/extensions/ros2-bridge/python/src/qos.rs b/libraries/extensions/ros2-bridge/python/src/qos.rs index 626934f5..33412f56 100644 --- a/libraries/extensions/ros2-bridge/python/src/qos.rs +++ b/libraries/extensions/ros2-bridge/python/src/qos.rs @@ -1,5 +1,6 @@ use ::dora_ros2_bridge::rustdds::{self, policy}; use pyo3::prelude::{pyclass, pymethods}; +use pyo3_special_method_derive::{Dict, Dir, Repr, Str}; /// ROS2 QoS Policy /// @@ -12,7 +13,7 @@ use pyo3::prelude::{pyclass, pymethods}; /// :type keep_last: int, optional /// :rtype: dora.Ros2QoSPolicies /// -#[derive(Debug, Clone)] +#[derive(Clone, Str, Repr, Dir, Dict)] #[pyclass] #[non_exhaustive] pub struct Ros2QosPolicies { @@ -77,7 +78,7 @@ impl From for rustdds::QosPolicies { /// DDS 2.2.3.4 DURABILITY /// /// :rtype: dora.Ros2Durability -#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Str, Repr, Dir, Dict)] #[pyclass] pub enum Ros2Durability { Volatile, @@ -103,7 +104,7 @@ impl From for policy::Durability { /// DDS 2.2.3.11 LIVELINESS /// :rtype: dora.Ros2Liveliness -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, PartialEq, Str, Repr, Dir, Dict)] #[pyclass] pub enum Ros2Liveliness { Automatic,