Trait rustdds::Key

source ·
pub trait Key: Eq + PartialEq + PartialOrd + Ord + Hash + Clone + Serialize + CdrEncodingSize {
    // Provided method
    fn hash_key(&self, force_md5: bool) -> 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§

source

fn hash_key(&self, force_md5: bool) -> KeyHash

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Key for bool

source§

impl Key for char

source§

impl Key for i8

source§

impl Key for i16

source§

impl Key for i32

source§

impl Key for i64

source§

impl Key for i128

source§

impl Key for u8

source§

impl Key for u16

source§

impl Key for u32

source§

impl Key for u64

source§

impl Key for u128

source§

impl Key for ()

source§

fn hash_key(&self, _force_md5: bool) -> KeyHash

source§

impl Key for String

Implementors§

source§

impl Key for Gid

source§

impl Key for GUID