Module key_data

Source
Expand description

Hacks to extract the version and index from a slotmap key, using serde.

This approach may fail in the future if slotmap changes its serde output; but that would probably break a bunch other tools that depend on slotmap.

§Performance

This serde-based approach might look inefficient, but the compiler is smart: it can inline all of the code and turn key_data_parts into direct data lookups.

(Note that this performance property requires us to use opt-level = 2 for this crate, in contrast with the rest of Arti, which currently prefers opt-level = "s".)

To conform that performance is likely acceptable, run cargo asm slotmap_careful::key_data::key_data_parts, and confirm that the result would fit on a napkin.

Macros§

shared_no_ops 🔒
Helper: Define the common members of Ser and SerU32.

Structs§

Failed 🔒
An unexpected failure from serializing a key.
Ser 🔒
Serializer for slotmap::KeyData, to extract the version and index of a key.
SerU32 🔒
Serializer that extracts a u32, and rejects anything else.

Functions§

key_data_parts 🔒
Decode a slotmap::KeyData into its version and index components.
key_version_serde 🔒
Return the version encoded in key.