Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate associated constants indicating serialized size for *Report types #74

Open
CobaltCause opened this issue Oct 15, 2024 · 2 comments

Comments

@CobaltCause
Copy link

To implement this, a new trait like this could be added:

pub trait ReportSize {
    const BYTES_COUNT: usize;
}

and then an implementation of this trait is generated for report types automatically by #[gen_hid_descriptor]. I'm not sure if there needs to be two associated constants, one for input and output, or if they're always the same size and so one associated constant would suffice.

This would be useful for automatically statically allocating buffers via the type system instead of having to hard-code magic numbers.

@twitchyliquid64
Copy link
Owner

Thats a great idea!

@HaoboGu
Copy link

HaoboGu commented Nov 22, 2024

I have the same issue, having ReportSize would be much helpful. @twitchyliquid64 @CobaltCause Do you have any plan for adding this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants