-
-
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
Passing a struct in ctx creates opaque error #408
Comments
This is caused, somehow by the act of passing a struct instead of a primitive type in the ctx; passing the |
Not at my computer, but could you try out the master branch? I think this is a duplicate of the fix MR here. |
@wcampbell0x2a - any chance you could merge #387 to master? Best thing since sliced bread for writing parsers for undocumented protocols where you need that "whatever is left over" set of bytes to still get parsed while you figure out the preceding structures/deps. Currently using it so would be swell to not have to comment-out the WIP stuff to test the stuff i think should work :) |
Merged |
Just about there. Trying to pass the struct by reference results in: 169 | #[deku(ctx = "hdr")]
| ^^^^^ expected `SvcHeader`, found `&SvcHeader` and trying to do it by value violates the borrow checker: 169 | #[deku(ctx = "*hdr")]
| ^^^^^^ move occurs because `*hdr` has type `SvcHeader`, which does not implement the `Copy` trait Deriving |
@sempervictus Checkout #411 for a fix for this. Sorry I didn't have time today to find an actual solution. I think. |
@wcampbell0x2a thank you, that PR's a brainfull so to speak... Lots of reading ahead on my end to actually figure out the codegen being done by those macros at some point 😄. That said, does cloning the pat type impact mutability of the enum's contents? If that's rebased off current master i'll give it a whirl when i go back to that piece of code. If its not too much trouble, and you happen to know - what does the derivation of cloning/copying do for actual mutability of content given that we're working off an underlying byte stream? Protocol machinations such as proxies need to alter those existing streams in-flight (making the inability to use |
Using non-adjacent fields to determine and then read enum types per https://github.com/sharksforarms/deku/blob/master/examples/enums.rs appears to get convoluted when endianness and identifiers are in the context. Specifically:
doesn't compile due to:
being thrown from the
SvcBody
enumThe text was updated successfully, but these errors were encountered: