Skip to main content

Key

Type Alias Key 

Source
pub type Key<T> = <T as Topicable>::Key;
Expand description

Evaluates to the Key type associated with the Topicable type T.

ยงExamples

use cyclonedds::{Key, Topicable};

#[derive(Topicable, serde::Serialize, serde::Deserialize, Default, Clone, Debug)]
struct Data {
    #[dds(key)]
    pub x: i32,
    #[dds(key)]
    pub y: i32,
    pub message: String,
}

let data = Data {
    x: 1,
    y: 2,
    ..Data::default()
};

// Access the `Key` of `Data` via the type alias.
let key = Key::<Data> { x: 1, y: 2 };

// The keys are equal.
assert_eq!(key, data.as_key());