-
-
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
Conditional Skip #63
Labels
enhancement
New feature or request
Comments
I like the idea! Shouldn't be too hard to implement. I can get to it next week most likely, also reminds me of a |
sharksforarms
added a commit
that referenced
this issue
Jul 27, 2020
sharksforarms
added a commit
that referenced
this issue
Jul 28, 2020
sharksforarms
added a commit
that referenced
this issue
Jul 28, 2020
If you don't mind taking a look to see if it meets your use-case, I plan on making a release tomorrow morning. In the case of your original ticket: use deku::prelude::*;
use std::convert::TryFrom;
#[derive(PartialEq, Debug, DekuRead, DekuWrite)]
pub struct DekuTest {
pub field_a: u8,
#[deku(skip, cond="*field_a == 1")] // skip if field_a == 1
pub field_b: Option<u8>,
#[deku(skip, cond="*field_b == Some(1)")] // skip if field_b == Some(1)
pub field_c: Option<u8>,
}
fn main() {
let data: Vec<u8> = vec![0x01, 0x02];
let value = DekuTest::from_bytes((data.as_ref(), 0)).unwrap();
println!("{:#?}", value)
}
|
I shall |
sharksforarms
added a commit
that referenced
this issue
Jul 28, 2020
Perfect, works as expected |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great idea of a library.
I have a protocol that needs conditional parsing of fields in a struct. I see the skip attribute, but would something like a conditional skip be possible?
The text was updated successfully, but these errors were encountered: