ManageIQ / ManageIQ/binary_struct
Supporting bit decoding and encoding
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 5
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
I'd like to specify the following:
BinaryStruct.decode([
'L', :some_num,
'b', :flag1,
'b', :flag2,
'b', :flag3,
'L', :another_num,
])
Given that, I'd expect BinaryStruct.decode to extract a number, then on the next byte extract the first 3 bits as booleans stored in :flag1, :flag2, :flag3, then move ahead to the next byte and extract another number.
I'd probably be happy with having to align my definition to byte boundaries, so perhaps...
BinaryStruct.decode([
'L', :some_num,
'b', :flag1,
'b', :flag2,
'b', :flag3,
'b5', :unused, # ideally optional
'L', :another_num,
])
I would expect encode and size to handle similar structures.
Implementation wise, the 'b' identifier reads 1 bit then skips to the next byte, So, when building the decode string it will have to be aware of successive bits and then pack those into a b8.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the BinaryStruct.decode, encode, and size entry points and inspect how format identifiers are currently parsed and packed. Define support for successive bit fields with optional padding and byte alignment, then verify that decoding, encoding, and size calculation agree for the structures shown in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100