pub trait Key: Eq + PartialEq + PartialOrd + Ord + Hash + Clone + Serialize + DeserializeOwned + CdrEncodingSize {
    fn hash_key(&self) -> KeyHash { ... }
}
Expand description

Trait for instance lookup key in a WITH_KEY topic.

The corresponding data sample type must implement Keyed. If the topic is NO_KEY, both of these can be ignored.

It is a combination of traits from the standard library

and Serde traits

and a RustDDS-specific trait

No other methods are required, so for many types it should be possible to #[derive] all the prerequisite traits and implement as impl Key for Foo {}. Consider also deriving Copy for your key, if the usual preconditions are satisfied.

Note: When implementing Key, DeserializeOwned cannot and need not be derived, as it is a type alias. Derive (or implement) the Deserialize trait instead.

Example

use rustdds::*;
use serde::{Serialize, Deserialize};

#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord,
         Serialize, Deserialize, CdrEncodingSize)]
pub struct MyKey {
  number: u32,
  name: String,
}

impl Key for MyKey {}

Provided methods

Implementations on Foreign Types

Implementors