Skip to content
Discussion options

You must be logged in to vote

You should be able to use the TakeSeek stream wrapper to limit the size of the stream plus the until_eof helper to read through the end of that data:

use binrw::io::TakeSeekExt;

#[derive(BinRead, BinWrite, Debug, Clone)]
pub struct EDK2VariableStore {
    pub size_in_bytes: u32,

    #[br(align_after = 4, map_stream = |s| s.take_seek(size_in_bytes.into()), parse_with = binrw::helpers::until_eof)]
    pub variables: Vec<VariableEntry>,

   pub something_else :u32,
    ....
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@madushan1000
Comment options

@madushan1000
Comment options

Answer selected by Mimoja
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #195 on April 05, 2023 15:57.