jam1garner / jam1garner/binread
Relative Offsets
- Dominant language
- Rust
- Stars
- 267
- Forks
- 17
- PR merge metrics
- No merged PRs in 30d
Description
I have scoured through the documentation and there doesn't seem to be a way to handle offsets relative to the start of a struct.
Looking at the implementation in `file_ptr.rs` it seems trivial to implement.
One could imagine it looking like
```rust
#[derive(BinRead)]
#[br(offsets=relative)]
struct Foo {
bar: FilePtr32
}
```
where the `bar.offset` would be relative to the position of `Foo` in the stream.
I'm writing this as an issue mostly to discuss any potential alternatives to this proposed design like the one in #13.
Contributor guide
No contributing guide indexed for this repository
Research direction
Read file_ptr.rs to understand how offsets are currently handled, then review issue #13 for the alternative design under discussion. Confirm how the proposed relative base should be defined for nested structs and determine the macro and parsing behavior needed for the example. Done means the chosen design is implemented and relative offsets resolve from the containing struct's stream position.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100