-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
Help passing context around #397
Comments
Remove unwrap causing the following error when the EnumExt tried to infer what type is was to return. An attribute could be added in the future to aid this, but for now we will just not emit the deku_id() for this type of enum. I decided in other causes (which aren't tested), to also remove the error and just not emit the function also. help: message: called `Result::unwrap()` on an `Err` value: Error("expected `,`") See #397
#398 appears to have fixed the issue! My case compiles and runs successfully. I did have to fix two issues: first I was moving the header via context instead of passing a reference, and second, the byte array input I gave encoded the u32 length as big-endian but the struct didn't tell Deku that, so it was trying to decode the length as little-endian (system default), so it didn't think there were enough bytes to fill the vec (technically true!), but once I fixed that it was all good. |
* Fix unknown id Type for EnumExt::deku_id() Remove unwrap causing the following error when the EnumExt tried to infer what type is was to return. An attribute could be added in the future to aid this, but for now we will just not emit the deku_id() for this type of enum. I decided in other causes (which aren't tested), to also remove the error and just not emit the function also. help: message: called `Result::unwrap()` on an `Err` value: Error("expected `,`") See #397 * clippy --------- Co-authored-by: Emmanuel Thompson <[email protected]>
Discussed in #396
Originally posted by alexjbuck January 2, 2024
I'm brand new to the Deku crate. Its really cool!
I'm looking to parse some binary packet data with this crate. The general structure of packets is a Header/Payload structure. The header is an Identifier and a total packet length (as u32).
My initial thought was to treat the payload section as an enum where the id is an external id passed from the header type through the context variable (referencing the docs)
Below is a minimal implementation for one variant but I'm getting a proc-macro error that I don't understand.
These are the errors:
I'd appreciate any pointers to what I may be doing wrong here.
The text was updated successfully, but these errors were encountered: