Skip to content

compile failed when deserilize msg struct #327

Closed
@fawdlstty

Description

@fawdlstty

Reproduction steps:

  1. enable serde in cargo.toml
[dependencies]
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
rclrs = "0.3"
rosidl_runtime_rs = "0.3"
std_msgs = "*"
nav_msgs = { version = "*", features = ["serde"] }
  1. serde json
let odom = nav_msgs::msg::Odometry::default();
let json_str = serde_json::to_string(&odom).unwrap();
  1. colcon build
  2. compile error info
--- stderr: fk_dumper_node                            
error[E0277]: the trait bound `[f64; 36]: Deserialize<'_>` is not satisfied
    --> /d/_work_projects/code_ros2/rust_ws/install/geometry_msgs/share/geometry_msgs/rust/src/msg.rs:156:21
     |
156  |     pub covariance: [f64; 36],
     |                     ^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `[f64; 36]`
     |
     = help: the following other types implement trait `Deserialize<'de>`:
               &'a [u8]
               [T; 0]
               [T; 10]
               [T; 11]
               [T; 12]
               [T; 13]
               [T; 14]
               [T; 15]
             and 26 others
note: required by a bound in `next_element`
    --> /home/fawdlstty/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.183/src/de/mod.rs:1733:12
     |
1731 |     fn next_element<T>(&mut self) -> Result<Option<T>, Self::Error>
     |        ------------ required by a bound in this associated function
1732 |     where
1733 |         T: Deserialize<'de>,
     |            ^^^^^^^^^^^^^^^^ required by this bound in `SeqAccess::next_element`

error[E0277]: the trait bound `[f64; 36]: Deserialize<'_>` is not satisfied
    --> /d/_work_projects/code_ros2/rust_ws/install/geometry_msgs/share/geometry_msgs/rust/src/msg.rs:156:21
     |
156  |     pub covariance: [f64; 36],
     |                     ^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `[f64; 36]`
     |
     = help: the following other types implement trait `Deserialize<'de>`:
               &'a [u8]
               [T; 0]
               [T; 10]
               [T; 11]
               [T; 12]
               [T; 13]
               [T; 14]
               [T; 15]
             and 26 others
note: required by a bound in `next_value`
    --> /home/fawdlstty/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serde-1.0.183/src/de/mod.rs:1872:12
     |
1870 |     fn next_value<V>(&mut self) -> Result<V, Self::Error>
     |        ---------- required by a bound in this associated function
1871 |     where
1872 |         V: Deserialize<'de>,
     |            ^^^^^^^^^^^^^^^^ required by this bound in `MapAccess::next_value`
  1. generated file in /d/_work_projects/code_ros2/rust_ws/install/geometry_msgs/share/geometry_msgs/rust/src/msg.rs:156:21
// Corresponds to geometry_msgs__msg__AccelWithCovariance
#[repr(C)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub struct AccelWithCovariance {
    pub accel: crate::msg::rmw::Accel,
    pub covariance: [f64; 36],
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions