Skip to main content

pad_to_fixed

Function pad_to_fixed 

Source
pub fn pad_to_fixed<'a>(
    seq: &[u8],
    max_len: usize,
    buf: &'a mut [u8],
) -> &'a [u8] 
Expand description

Pad a variable-length sequence to a fixed width using the collision-free padding scheme.

  • seq: the extracted sequence (may be shorter than max_len)
  • max_len: the maximum length (from GeoLen::Range(_, max))
  • buf: a caller-provided buffer of at least max_len bytes

Returns a slice of buf containing the padded sequence (length == max_len).

If seq.len() == max_len, the original bytes are copied without padding. If seq.len() < max_len, the appropriate padding suffix is appended.

§Panics

Panics if the deficit (max_len - seq.len()) exceeds [MAX_RANGE_WIDTH].