Skip to main content

encode_composite_key

Function encode_composite_key 

Source
pub fn encode_composite_key(fields: &[&str]) -> String
Expand description

Encodes fields into one string that is injective in the field tuple: distinct inputs always produce distinct outputs and equal inputs produce equal outputs, whatever the fields contain.

Each field is length-prefixed ({byte_len}:{field}). The byte count, read up to the first :, fixes each field’s boundary unambiguously even when a field contains : or leading digits, so the concatenation is a prefix-free code. The result is an opaque identity token, not intended to be parsed back.

§Performance

This function is O(total field bytes) with a single output allocation.