Skip to content

Evaluate exact decoded_len and validation-only check APIs #12

Open

Description

@tisonkun

Context

Codec::max_decoded_len(usize) -> usize inspects only the encoded byte count and returns an upper bound on padded inputs (such as 3 for "AA==", which decodes to 1 byte), even though the internal decode_plan step already computes the exact decoded length in O(1) time by inspecting trailing = characters and validating length and padding shape. Separately, ingestion pipelines and protocol parsers occasionally need to verify strict RFC 4648 conformance without allocating or writing decoded bytes.

Considerations

  • Evaluate exposing decoded_len(input: impl AsRef<[u8]>) -> Result<usize, DecodeError> so caller-buffer users can size exact slices when input is already available.
  • Evaluate exposing check(input: impl AsRef<[u8]>) -> Result<(), DecodeError> backed by validation-only fast paths that skip bit-packing and output stores while preserving exact DecodeError precedence and byte offsets.
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