Skip to main content

encode_smallest

Function encode_smallest 

Source
pub fn encode_smallest(
    candidates: &[u32],
    payload: &[u8],
) -> Result<(u32, Vec<u8>)>
Expand description

Cost-driven encoder: try every candidate wire encoding and return the (encoding_id, bytes) of the SMALLEST result, so the writer can record the chosen id in the section entry. Ties break toward the EARLIEST candidate (cheaper-to-decode wins an equal-size race). This only auto- picks among non-embedding encodings; existing presets that name an encoding explicitly are untouched, so the frozen output stays byte-identical.