Trait Keyed

Source
pub trait Keyed {
    type K: Key;

    // Required method
    fn key(&self) -> Self::K;
}
Expand description

Data sample must implement Keyed to be used in a WITH_KEY topic.

It allows a Key to be extracted from the sample. In its simplest form, the key may be just a part of the sample data, but it can be anything computable from an immutable sample by an application-defined function. It is recommended that this function be lightweight to compute.

The key is used to distinguish between different Instances of the data in a DDS Topic.

DDS WITH_KEY Topics are similar to distributed key-value maps. A Sample corresponds to a key-value-pair and the Keyed trait allows to extract the key out of the pair. An Instance means all the Samples with the same Key. These samples can be viewed as updates to the key. WITH_KEY topics also support a Dispose operation, which corresponds to removing a key from the map.

A Keyed type has an associated type K, which is the corresponding key type. K must implement Key. Otherwise, K can be chosen to suit the application. It is advisable that K is something that can be cloned with reasonable effort.

Required Associated Types§

Source

type K: Key

Required Methods§

Source

fn key(&self) -> Self::K

Implementations on Foreign Types§

Source§

impl<D: Keyed> Keyed for &D

Key for a reference type &D is the same as for the value type D. This is required internally for the implementation of NoKey topics.

Source§

type K = <D as Keyed>::K

Source§

fn key(&self) -> Self::K

Implementors§