Skip to content

Evaluate const fn encoding/decoding and stack buffer helpers #14

Open

Description

@tisonkun

Context

Concrete profile constructors and sizing methods (encoded_len, max_decoded_len) are already const fn, but encoding and decoding themselves cannot yet be evaluated at compile time (for example const KEY: [u8; 32] = ...; in protocol constants and test vectors, where crates otherwise pull in hex-literal or const-hex). Formatting short digests onto the stack also currently takes two statements (let mut buf = [0_u8; N]; let s = Base16Lower::encode_into(bytes, &mut buf)?;).

Considerations

  • Because stable const fn cannot accept impl AsRef<[u8]> bounds, evaluate whether dedicated const fn slice/array helpers (such as decode_array_const::<N>(&[u8])) justify the extra method surface.
  • Evaluate whether an itoa-style stack formatting buffer or fixed-array encode helper adds enough convenience over encode_into + const { Profile::encoded_len(N) } and EncodedDisplay.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions