Skip to content

Features to support optional-numeric-index #3058

Closed as duplicate
Closed as duplicate

Description

@sebschmi

What is the name of your project?
optional-numeric-index

Please provide a link to your project (GitHub repository, crates.io page, etc).
https://github.com/sebschmi/optional-numeric-index

What features would you like from zerocopy?

  • Allow types to specify custom valid byte patterns.
    The optional-numeric-index crate provides macros to create custom types to index e.g. vectors. These come in pairs, where one is the normal index type and one is an optional index type. For a compact representation, the bit-pattern that corresponds to the maximum value of the index is reserved for a None value. Hence, it is invalid for the normal index type.
    Currently, zerocopy has no way of handling that, as it does not allow to manually restrict the valid bit-patterns of a type. Deriving TryFromBytes for one of these custom index types would allow the maximum value as a valid bit pattern. What our project would need is a way to pass a filter function to #[derive(TryFromBytes)] that can reject bit patterns as needed.

Activity

  1. joshlf commented on Feb 16, 2026

    @joshlf
    Member

    Sounds like you're describing "custom validators", which we're tracking in #1330. Feel free to re-open if that doesn't address what you need!

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions