-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
How to use the size in an inner struct #368
Comments
I found an alternative solution by using the It would still be interesting to know how to use size. |
Since you added use deku::prelude::*;
#[derive(Debug, PartialEq, DekuRead)]
struct Outer {
outer_a: u8,
#[deku(ctx = "deku::rest.len()/8-2")]
outer_b: Inner,
outer_c: u8,
}
#[derive(Debug, PartialEq, DekuRead, DekuWrite)]
#[deku(ctx = "size: usize")]
struct Inner {
inner_a: u8,
#[deku(count = "size - deku::byte_offset - 2")]
inner_b: Vec<u8>,
inner_c: u8,
} Unfortunately, this variable |
I don't understand how the code changes you suggested are related to what you wrote. You used different solutions I tried in Outer and Inner context, while you referred to 'same context' in your text?
I want to make sure I understand what you mean - I can't use deku:rest.len() in the writing? I don't see how it could work in writing as there isn't 'rest' when writing if I get it right. Or maybe I'm totally off? But same would go for size. |
In the following example, the buffer is of an unknown size and I want to get the inner_b to contain all bytes that are not included in fields prior and after it in the hierarchical structures.
I get the following error:
I assume that I need to somehow pass the size of the buffer from the outer struct to the inner context, but couldn't find how to do that. Is there a way? Or any other way to achieve what I'm trying to do?
The text was updated successfully, but these errors were encountered: