#[derive(Topicable)]
{
// Attributes available to this derive:
#[dds]
}
Expand description
Derives Topicable for a named-field struct.
Fields annotated with #[dds(key)] are collected into a generated
<Name>Key struct that implements CdrBounds. Structs with no
#[dds(key)] fields use () as their key type and must
implement [Default].
An optional #[dds(type_name = "...")] attribute overrides the DDS type
name used for topic matching. Without it, the Rust type name is used.
§Examples
ⓘ
#[derive(cyclonedds::Topicable, serde::Serialize, serde::Deserialize, Default, Clone, Debug)]
#[dds(type_name = "MySensor")]
pub struct Sensor {
#[dds(key)]
pub id: u32,
pub value: f32,
}
// NOTE: this results in a hidden module being generated `__cyclonedds_topicable_Sensor`
// containing the following type: `Key { pub id: u32 }`§Panics
Panics at compile time if applied to an enum, a union, a tuple struct, or
if #[dds(type_name)] is not a valid string literal.