Skip to main content

Module key_data

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.