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

Conditional skip option #27

Open
carsonfarmer opened this issue Sep 16, 2022 · 0 comments
Open

Conditional skip option #27

carsonfarmer opened this issue Sep 16, 2022 · 0 comments

Comments

@carsonfarmer
Copy link

Hi I'm just wondering if it is possible to provide a conditional skip option, similar to how length is able to use values from previous fields. For example, say I have the following struct:

#[derive(PartialEq, Debug, Readable, Writable)]
struct Page {
    flag: bool,
    #[speedy(skip=flag)]
    conditional: u32
}

In this case, both read and write would "skip" the conditional field if the flag were set to false, and both would include them if set to true.

Is there perhaps a different way to achieve the same result? In my case, I am dealing with an existing encoding format, so I am trying to find ways to get speedy to work in this case.

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

1 participant