#size #encoding #derive-macro #data #computing #cdr

cdr-encoding-size

Helper crate for RustDDS: Trait to compute CDR-serialized size of data

1 unstable release

0.5.0 Nov 4, 2021

#1677 in Algorithms

Download history 277/week @ 2023-10-19 464/week @ 2023-10-26 465/week @ 2023-11-02 510/week @ 2023-11-09 317/week @ 2023-11-16 333/week @ 2023-11-23 362/week @ 2023-11-30 665/week @ 2023-12-07 283/week @ 2023-12-14 339/week @ 2023-12-21 131/week @ 2023-12-28 536/week @ 2024-01-04 227/week @ 2024-01-11 434/week @ 2024-01-18 333/week @ 2024-01-25 116/week @ 2024-02-01

1,169 downloads per month
Used in 3 crates (2 directly)

Apache-2.0

6KB
77 lines

This crate specifies the CdrEncodingSize trait. It is a helper to the RustDDS library.

The trait is in a separate crate, because it has a derive-macro.

The RTPS specification version 2.5 Section "9.6.4.8 KeyHash (PID_KEY_HASH)" defines an algorithm for computing a 16-byte hash of a DDS Key of a data sample.

The algorithm summary:

  • Define a "holder" type corresponding to the data sample type.
  • The holder type consists of all the fields that form the Key of the data sample type.
  • The holder type is serialized according to PLAIN_CDR2 Big Endian.
  • If the holder type has maximum serialized size of at most 16 bytes, the serialized representation is the key hash, padded with zero bytes to 16 bytes.
  • If the holder type has maximum serialized size of more then 16 bytes, key hash is the MD5 hash of the serialized representation.
  • This always results in a key hash of exactly 16 bytes.

This trait is a means of deciding if the 16-byte limit is exceede, i.e. if MD5 shold be used or not.

Dependencies

~1.5MB
~33K SLoC