Discontinuous view section support #110
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR extends the pattern language's concept of sections to be more polymorphic. A section is defined as a (not necessarily contiguous!) area of address space which can be read/written with chunked IO operations, and can provide additional information about the chunks of data it contains.
This generalisation allows the implementation of "view sections". These sections don't host chunks themselves, instead they are a view over spans of already existing sections, such as the ones that can be created with
std::mem::create_section
, or the main section itself.This allows parsing patterns over discontinuous area of the main section as-if the data was laid out linearly. For example:
This PR includes API breakage! The pattern language no longer exposes custom sections as
std::vector<u8>
, but providesapi::Section
s instead, which can be easily read to obtain their data.Additionally, sections now may contain discontinuous data which requires additional care when rendering their contents, as trying to read unmapped areas of a section will result in an
IOError
being returned.To support this usecase sections provide an API which may be used to iterate over their chunks' attributes.
Commit-by-commit review is highly advised!